rate-limit-express
v2.2.2
Published
+ Rate limit middleware to limit access. + Everytime a user sends a request to the server, ipaddress of the user is the key and the number of times visited is increased by one. + This function also sets of a callback function which gets triggered after **
Downloads
72
Readme
Rate limiting:
- Rate limit middleware to limit access.
- Everytime a user sends a request to the server, ipaddress of the user is the key and the number of times visited is increased by one.
- This function also sets of a callback function which gets triggered after timelimit(second parameter) seconds and reduces the number of times visited by one.
- So we effectively keep the ipaddress and number of requests in the last timelimit seconds window.
- If it is greater than the requestlimits(firstparameter), we send an error message.
Usage:
- const ratelimiter = require("rate-limit-express");
- app.use(ratelimiter.ratelimit(5, 10));
- app is your Express app and first parameter is timelimit and second parameter is access limit