Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

express-rate-limit

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-rate-limit - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

2

package.json
{
"name": "express-rate-limit",
"version": "3.0.0",
"version": "3.0.1",
"description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/nfriedly/express-rate-limit",

@@ -40,10 +40,9 @@ # Express Rate Limit

```js
var RateLimit = require("express-rate-limit");
const rateLimit = require("express-rate-limit");
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
var limiter = new RateLimit({
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
delayMs: 0 // disable delaying - full speed until the max limit is reached
max: 100 // limit each IP to 100 requests per windowMs
});

@@ -58,10 +57,9 @@

```js
var RateLimit = require("express-rate-limit");
const rateLimit = require("express-rate-limit");
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
var apiLimiter = new RateLimit({
const apiLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100,
delayMs: 0 // disabled
max: 100
});

@@ -76,17 +74,14 @@

```js
var RateLimit = require("express-rate-limit");
const rateLimit = require("express-rate-limit");
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
app.enable("trust proxy"); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
var apiLimiter = new RateLimit({
const apiLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100,
delayMs: 0 // disabled
max: 100
});
app.use("/api/", apiLimiter);
var createAccountLimiter = new RateLimit({
const createAccountLimiter = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hour window
delayAfter: 1, // begin slowing down responses after the first request
delayMs: 3 * 1000, // slow down subsequent responses by 3 seconds per request
max: 5, // start blocking after 5 requests

@@ -106,4 +101,2 @@ message:

- **windowMs**: milliseconds - how long to keep records of requests in memory. Defaults to `60000` (1 minute).
- **delayAfter**: max number of connections during `windowMs` before starting to delay responses. Defaults to `1`. Set to `0` to disable delaying.
- **delayMs**: milliseconds - how long to delay the response, multiplied by (number of recent hits - `delayAfter`). Defaults to `1000` (1 second). Set to `0` to disable delaying.
- **max**: max number of connections during `windowMs` milliseconds before sending a 429 response. Defaults to `5`. Set to `0` to disable.

@@ -158,2 +151,7 @@ - **message**: Error message returned when `max` is exceeded. Defaults to `'Too many requests, please try again later.'`

* store is finished.
*
* The callback should be triggered with three values:
* - error (usually null)
* - hitCount for this IP
* - resetTime, in seconds from the epoch (optional, but necessary for X-RateLimit-Reset header)
*/

@@ -160,0 +158,0 @@ this.incr = function(key, cb) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc