2.0.4 • Published 4 years ago

ratelimiter-middleware v2.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

ratelimiter-middleware

npm.io npm.io

Basic rate-limiting middleware for Express. Used to limit repeated requests to public APIs and/or endpoints. It can be used to rateLimit a specific appId (specified in the request headers) and by default it rateLimits IP addresses.

Ensure that your redis server is running before using

Installation

npm i --save ratelimiter-middleware

Usage

const express = require('express');
const app = express();
const rateLimiter = require('ratelimiter-middleware');

const maxRequests = 100;
const timeLimit = 60; // seconds
const appId = 'appId'; // The request header that you specify

app.use(rateLimiter(maxRequests,timeLimit, appId));

// The appId parameter can be left empty if you want to rateLimit based
// on IP address
// eg. app.use(rateLimiter(maxRequests,timeLimit));

app.get('/', (req, res) => {
  res.json({ msg: 'AoK' });
});
2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago