#Passing module options to the guard inside controller
6 messages · Page 1 of 1 (latest)
Why do you want to do this?
My module has rate limiting options for each route. I need to pass them dynamically to the decorator in order to use them in guard. Something like this:
@Controller()
export class MyController {
constructor(@Inject('MODULE_OPTIONS') private options: ModuleOptions) {}
@MyGuardDecorator(options.rateLimiting.route1)
//...
@MyGuardDecorator(options.rateLimiting.route2)
//...
}
for each route.
That would be per guard put on each route then? So, specialized guards for each route? Does each route definitely have a different rate limit? Sorry, but this makes little sense as it is. I need more context. Why do you wish to have possibly totally differing throttling config per route?
Yes, I need the ability to set rate limiting for each route. I know this is a rare case, but that's the requirement.
And you need much more fidelity than this?
https://docs.nestjs.com/security/rate-limiting#multiple-throttler-definitions