node-rate-limiter-flexible icon indicating copy to clipboard operation
node-rate-limiter-flexible copied to clipboard

Revise Documentation

Open jeremykentbgross opened this issue 1 year ago • 1 comments

I don't know if it is just me, but I found the documentation for blockduration to be very unclear as written at: https://github.com/animir/node-rate-limiter-flexible/wiki/Options#blockduration

From experimentation I would say that duration is mostly clear, but could be improved from:

Number of seconds before consumed points are reset.

To something like:

Number of seconds before consumed points are reset, starting from the time of the first consumed point on a key. (ie: How long to remember points for a key after the first consumption of/on it.)

But mainly I would consider revising blockduration to say something like:

While duration will cause the points to be remembered for the given interval after the first consumption of a key, and block when all points are consumed until it is reset after an interval given by the duration, blockduration will cause the reset to happen sooner once a key is actually blocked.

Maybe these suggested changes are not perfect, ideal or even suitable either, but I found myself confused by the docs as written, and it was only by modifying a working version of the example at https://github.com/animir/node-rate-limiter-flexible/wiki/Overall-example#login-endpoint-protection to have much shorter duration and blockduration that I was able to deduce what they were really doing. I figured that if I had some trouble with this, then others might also, so I would leave behind a note about it, and make a suggestion for improvement.

jeremykentbgross avatar Apr 30 '24 16:04 jeremykentbgross

@jeremykentbgross I improved the description based on your feedback. Could you check if it is clear now? Thank you!

animir avatar May 05 '24 15:05 animir

My apologies for not replying 2 weeks ago. I only now saw the notifications last night in my inbox with it being marked complete. Looking at it now it seems clear, but I would need to refresh my memory with some tests to be sure I am not mistaken. I trust your judgement on the correction though, as it seems much clearer than before and I am sure you understand the internal functionality better than I do in terms of it being an accurate description.

jeremykentbgross avatar May 20 '24 23:05 jeremykentbgross