peterkhayes/rolling-rate-limiter

Setting maxInInterval: 1 doesn't work properly

hallcyon11 opened this issue · 1 comments

I use this module as middleware. Users have to wait 10 minutes between posts. The first time a request is made the "actionsLeft" changes to 0 and the timeLeft is 0. The second time a request is made "actionsLeft" changes to -1 and timeLeft changes to 10 minutes in ms, which is what I expect but only to happen after the first request. Can it just be changed so maxInInterval can be set to 0 or am I doing something wrong? Thank you.

I think in your case, maxInInterval should be set to 1 and interval should be set to 600000.

Additionally, there is a new version of this library out. You can see the release notes here. One feature is the limitWithInfo method, which will give additional information that may help.