This library serves as Express middleware designed to make a yes/no decision about whether to admit a request or to determine that a request has exceeed a threshold and should be rejected with a HTTP 429 or other relevant HTTP response.
(See the /test folder in the project for more examples)
const RateLimiter = ;var rlm =redis:port: 6379host: '127.0.0.1'db: 0;app;
you can also pass in an existing Redis client like so:
const RateLimiter = ;var rlm =redis:client: yourClient;
Note: This library calls your error handling middleware. When the rate limit is exceeded by the newest request it will call your promixate error handling middleware; this same middleware will also be called if any other types of errors occur. All errors (whether they are Redis errors or rate limit errors) should be handled by you like this:
That might look like this: