Skip to content

shubham9069/RATE_LIMITER-Npm-Package

Repository files navigation

SHADOW-RATE-LIMITTER PACKAGE BUNDLE

shadow-ui

checkout this Ui component created by shadow:- https://github.com/shubham9069/Shadow-UI-React-Example

Badges

MIT License GPLv3 License AGPL License

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`)
});

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published