express-brute
express-brute copied to clipboard
Retrieve number of remaining requests
Hi,
I'm using express-brute as a rate limiter for my API, allowing for example a maximum of 3600 requests per IP per hour. I would like to give some information regarding rate limit through headers on every response (even those that are not rate limited), especially the following ones:
- RateLimit-Count: number of requests already received from the beginning of the time frame.
- RateLimit-Reset: date when the time frame is reset. I know there is a 'nextValidRequestDate' argument provided in 'failCallback', but I can't see any way to get that information from a successful request.
Is there a way to do it?
PS: I'm using the in-memory store at the moment.
Any updates on this from the maintainers? Much appreciated!
This isn't a feature that's currently implemented, but I'd welcome pull requests with tests. My thought is we'd probably want something similar to the attachResetToRequest
option that allows those stats to be attached to the request object as well (rather than just setting headers on the request directly).