rate-limiter-flexible
Advanced tools
Comparing version 0.15.3 to 0.15.4
@@ -45,3 +45,3 @@ const RateLimiterStoreAbstract = require('./RateLimiterStoreAbstract'); | ||
this._clearExpiredTimeoutId = setTimeout(() => { | ||
const expire = new Date(Date.now() - 3600000); | ||
const expire = Date.now() - 3600000; | ||
const q = { | ||
@@ -68,3 +68,3 @@ name: 'rlflx-clear-expired', | ||
points integer NOT NULL DEFAULT 0, | ||
expire timestamp NOT NULL | ||
expire bigint NOT NULL | ||
);`; | ||
@@ -89,3 +89,3 @@ } | ||
res.remainingPoints = Math.max(this.points - res.consumedPoints, 0); | ||
res.msBeforeNext = Math.max(new Date(row.expire).getTime() - Date.now(), 0); | ||
res.msBeforeNext = Math.max(row.expire - Date.now(), 0); | ||
@@ -100,7 +100,7 @@ return res; | ||
const newExpire = new Date(Date.now() + msDuration); | ||
const newExpire = Date.now() + msDuration; | ||
const expireQ = forceExpire | ||
? ' $3 ' | ||
: ` CASE | ||
WHEN ${this.tableName}.expire < $4 THEN $3 | ||
WHEN ${this.tableName}.expire <= $4 THEN $3 | ||
ELSE ${this.tableName}.expire | ||
@@ -114,3 +114,3 @@ END `; | ||
points = CASE | ||
WHEN ${this.tableName}.expire < $4 THEN $2 | ||
WHEN ${this.tableName}.expire <= $4 THEN $2 | ||
ELSE ${this.tableName}.points + ($2) | ||
@@ -120,3 +120,3 @@ END, | ||
RETURNING points, expire;`, | ||
values: [key, points, newExpire, new Date()], | ||
values: [key, points, newExpire, Date.now()], | ||
}; | ||
@@ -137,3 +137,3 @@ | ||
SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND expire > $2;`, | ||
values: [rlKey, new Date()], | ||
values: [rlKey, Date.now()], | ||
}; | ||
@@ -140,0 +140,0 @@ |
{ | ||
"name": "rate-limiter-flexible", | ||
"version": "0.15.3", | ||
"version": "0.15.4", | ||
"description": "Flexible API rate limiter backed by Redis for distributed node.js applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95363