shadow-rate-limitter
v1.2.0
Published
rate limitter package This project is for open source contribution
Downloads
230
Maintainers
Readme
SHADOW-RATE-LIMITTER PACKAGE BUNDLE
checkout this Ui component created by shadow:- https://github.com/shubham9069/Shadow-UI-React-Example
Badges
Related Link
To install this package into another application as part of its production build steps, you can follow these general steps:-
1. Run npm install: during the production build process, run npm install to install dependencies. npm will fetch the package specified in the package.json and install it into the node_modules directory of your project.
2. Include the Package in Your Project: Run this command
npm i shadow-rate-limitter
Step to use:-
const {RateLimitter} = require("shadow-rate-limitter")
const rateLimitter = new RateLimitter()
const middleware1 = rateLimitter.userRateLimitter(max_Request, Time)
MiddleWare Function:-
const middleware1 = rateLimitter.userRateLimitter(max_Request, Time)
| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| max_Request
| Number
| Required. No of Request Allow|
| Time
| Number
| Required. Time period of (Time should be in milli secound )|
Example:-
const express = require("express");
const {RateLimitter} = require("shadow-rate-limitter")
const app = express();
const rateLimitter = new RateLimitter()
const middleware1 = rateLimitter.userRateLimitter(5,1000 * 10)
const middleware2 = rateLimitter.userRateLimitter(2,1000 * 10)
app.use(express.json());
app.get("/health-check1", middleware1,async function (req, res) {
return res.json({ status: 200, message: "100 % working " })
});
app.get("/health-check2", middleware2,async function (req, res) {
return res.json({ status: 200, message: "100 % working " })
});
app.listen(8000, async () => {
console.log(`Server Running...8000`)
});