Skip to content

Simple rate limiting for Koa2, supports clustered apps, blacklisting and whitelisting

License

Notifications You must be signed in to change notification settings

mhingston/koa-rate-limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-rate-limit

Simple rate limiting for Koa, supports clustered apps, blacklisting and whitelisting.

Install

npm install mhingston/koa-rate-limit

Usage

const rateLimit = require('koa-rate-limit');

Setup per-route middleware for rate limiting:

router.get('/', rateLimit({interval: 5 * 60 * 1000}), (ctx, next) =>
{
	ctx.body = 'Hello World!';
});

Configuration

  • interval {Integer} The rate limiting window (in milliseconds).
  • max {Integer} The maximum number of requests before rate limiting is applied.
  • whitelist {String[]} An array of default IP addresses to always allow (you can use CIDR notation).
  • blacklist {String[]} An array of default IP addresses to always deny (you can use CIDR notation).

About

Simple rate limiting for Koa2, supports clustered apps, blacklisting and whitelisting

Resources

License

Stars

Watchers

Forks

Packages

No packages published