How to set dynamic point and prefix in service nestjs ? #232
Answered
by
animir
supryantowp
asked this question in
Q&A
-
I'm working on a NestJS application that uses rate-limiter-flexible for rate limiting. I want to update the rate limiter's settings, specifically the points and keyPrefix properties, based on dynamic values obtained from a configuration object (throttle.limit and channel). How can I correctly implement this dynamic update in my code to achieve the desired rate limiting behavior?
|
Beta Was this translation helpful? Give feedback.
Answered by
animir
Nov 10, 2023
Replies: 1 comment 1 reply
-
it works but this is the correct way to solve problem ?
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @supryantowp
This question is more about what you exactly need. It is fair not only for NestJS.
If you don't need to keep previously consumed points they will be reset after this call
this.rateLimits.set(keyPrefix, rateLimiter)
.If you need to keep consumed points you can change
points
of already created limiter on the fly. Just callateLimiter.points = points
.I hope this answers your question.