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 2.12.2 to 2.13.0

17

lib/express-rate-limit.js

@@ -66,3 +66,3 @@ "use strict";

options.store.incr(key, function(err, current) {
options.store.incr(key, function(err, current, resetTime) {
if (err) {

@@ -75,3 +75,4 @@ return next(err);

current: current,
remaining: Math.max(options.max - current, 0)
remaining: Math.max(options.max - current, 0),
resetTime: resetTime
};

@@ -82,2 +83,14 @@

res.setHeader("X-RateLimit-Remaining", req.rateLimit.remaining);
if (resetTime) {
// if we have a resetTime, also provide the current date to help avoid issues with incorrect clocks
// format from https://stackoverflow.com/a/13219636/933879
res.setHeader(
"Date",
new Date()
.toISOString()
.replace(/T/, " ")
.replace(/\..+/, "")
);
res.setHeader("X-RateLimit-Reset", resetTime);
}
}

@@ -84,0 +97,0 @@

"use strict";
function calculateNextResetTime(windowMs) {
return Math.ceil((Date.now() + windowMs) / 1000);
}
function MemoryStore(windowMs) {
var hits = {};
var resetTime = calculateNextResetTime(windowMs);

@@ -12,3 +18,3 @@ this.incr = function(key, cb) {

cb(null, hits[key]);
cb(null, hits[key], resetTime);
};

@@ -25,2 +31,3 @@

hits = {};
resetTime = calculateNextResetTime(windowMs);
};

@@ -31,2 +38,3 @@

delete hits[key];
delete resetTime[key];
};

@@ -33,0 +41,0 @@

2

package.json
{
"name": "express-rate-limit",
"version": "2.12.2",
"version": "2.13.0",
"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",

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