express-throttler

1.1.0 • Public • Published

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!' });
    }
}));
 

Readme

Keywords

Package Sidebar

Install

npm i express-throttler

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • mattkrea