Skip to content

nuxt-contrib/reqlim

Repository files navigation

reqlim

Connect/Express middleware to limit requests based on express-rate-limit

Standard JS david dm codecov circleci

npm version npm downloads package phobia

Usage

Install package:

npm install reqlim

OR

yarn add reqlim

Import and use middleware:

const rateLimit = require('reqlim')

app.use(rateLimit())

Options

windowMs

  • Default: 1000

How long to keep records of requests in memory (milliseconds)

max

  • Default: 5

Max number of recent connections during window milliseconds before sending a 429 response

statusCode

  • Default: 429

Status when limit reached for Too Many Requests (RFC 6585)

headers

  • Default: true

Send custom rate limit header with limit and remaining

skipFailedRequests

  • Default: false

Do not count failed requests (status >= 400)

skipSuccessfulRequests

  • Default: false

Do not count successful requests (status < 400)

keyGenerator

  • Default: req => req.ip + '_' + req.url

Allows to create custom keys

getIP

Allows to create custom request IP getter

skip

  • Default: () => false

Skip certain requests

handler

Handler in case of reate limits

onLimitReached

A custom callback when rate limit reached

License

Based on https://github.com/nfriedly/express-rate-limit (MIT)

Made with 💖

Releases

No releases published

Packages

No packages published