@genezio/rate-limiter
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -55,3 +55,3 @@ "use strict"; | ||
const date = new Date(); | ||
const oldCount = await redisClient.get(`${args[0].requestContext.http.sourceIp}:${date.getMinutes()}`); | ||
const oldCount = await redisClient.get(`${args[0].requestContext.http.sourceIp}:${_context.name}:${date.getMinutes()}`); | ||
// If the limit is reached, throw an error | ||
@@ -68,4 +68,4 @@ if (oldCount && parseInt(oldCount) >= (_dict.limit ? _dict.limit : 50)) { | ||
.multi() | ||
.incr(`${args[0].requestContext.http.sourceIp}:${date.getMinutes()}`) | ||
.expire(`${args[0].requestContext.http.sourceIp}:${date.getMinutes()}`, _dict.refreshRate ? _dict.refreshRate : 59) | ||
.incr(`${args[0].requestContext.http.sourceIp}:${_context.name}:${date.getMinutes()}`) | ||
.expire(`${args[0].requestContext.http.sourceIp}:${_context.name}:${date.getMinutes()}`, _dict.refreshRate ? _dict.refreshRate : 59) | ||
.exec(); | ||
@@ -72,0 +72,0 @@ } |
@@ -55,3 +55,3 @@ "use strict"; | ||
const date = new Date(); | ||
const oldCount = await redisClient.get(`${args[0].requestContext.http.sourceIp}:${date.getMinutes()}`); | ||
const oldCount = await redisClient.get(`${args[0].requestContext.http.sourceIp}:${_context.name}:${date.getMinutes()}`); | ||
// If the limit is reached, throw an error | ||
@@ -68,4 +68,4 @@ if (oldCount && parseInt(oldCount) >= (_dict.limit ? _dict.limit : 50)) { | ||
.multi() | ||
.incr(`${args[0].requestContext.http.sourceIp}:${date.getMinutes()}`) | ||
.expire(`${args[0].requestContext.http.sourceIp}:${date.getMinutes()}`, _dict.refreshRate ? _dict.refreshRate : 59) | ||
.incr(`${args[0].requestContext.http.sourceIp}:${_context.name}:${date.getMinutes()}`) | ||
.expire(`${args[0].requestContext.http.sourceIp}:${_context.name}:${date.getMinutes()}`, _dict.refreshRate ? _dict.refreshRate : 59) | ||
.exec(); | ||
@@ -72,0 +72,0 @@ } |
{ | ||
"name": "@genezio/rate-limiter", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Rate limiter decorator for Genezio applications", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
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
17187