crud
crud copied to clipboard
CrudAuth applying to only particular routes
Is there an easy way to only have the filter function used in CrudAuth
apply to only certain routes? For instance I ran into an error when I wanted to have the filter apply to just the getOneBase
route, but it was applying to createOneBase
as well and user was undefined
causing an error.
The simplest way I can think of is to just override the function and decorate it, e.g.
@CrudAuth({your: options})
getOne (req: CrudRequest): Promise<School> {
return super.getOne(req);
}
If I do that suggestion 👆 I get “Unable to resolve signature of class decorator when called as an expression” in regards to the @CrudAuth decorating being there inside the class, rather than above the class.
There is a beautiful way to apply a decorator to a specific route, documented here: https://github.com/nestjsx/crud/wiki/Controllers#routes but the @CrudAuth decorator is not applying. No errors, just doesn't do the filter. Only seems to work when applied above the class to all routes.
Any suggestions?
Same here - its not possible to use @CrudAuth as a decorator for a route. It's only working for the whole Controller.