Skip to content

mattkrea/express-rate-limiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Throttler

Basic rate limiting for Express.js

Install

npm install express-throttler

Usage

'use strict';

const limiter = require('express-throttler');
const app = require('express')();

app.use(limiter({
	rpm: 60,                 // 60 requests per minute
	header: 'X-Access-Token' // identify the request with this header
}));

// You may also specify a handler if you want to do something other than
// return with { error: { code: 429, message: 'too many requests' } }
app.use(limiter({
	rpm: 60,
	handler: (req, res, next) => {
		return res.status(429).json({ MyFancyError: 'Try again next time!' });
	}
}));

About

Basic rate limiting for Express.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published