diff options
author | Erkin Alp Güney <erkinalp9035@gmail.com> | 2022-04-24 23:04:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 23:04:55 +0300 |
commit | aacf99d82a2b2dce609e7426396743c8cbcb7318 (patch) | |
tree | e64eab6148da70ff7c34d91f2ba4423840c7d9a4 | |
parent | Update Token.ts (diff) | |
download | server-aacf99d82a2b2dce609e7426396743c8cbcb7318.tar.xz |
Update RateLimit.ts
-rw-r--r-- | api/src/middlewares/RateLimit.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts index f31aa5da..4bbef520 100644 --- a/api/src/middlewares/RateLimit.ts +++ b/api/src/middlewares/RateLimit.ts @@ -70,8 +70,9 @@ export default function rateLimit(opts: { if (offender.blocked) { const global = bucket_id === "global"; - reset = reset + opts.window * 1000; // each block violation pushes the expiry one full window further - offender.expires_at = offender.expires_at + opts.window * 1000; + // each block violation pushes the expiry one full window further + reset = new Date(reset.getTime() + opts.window * 1000); + offender.expires_at = new Date(offender.expires_at.getTime() + opts.window * 1000); resetAfterMs = reset - Date.now(); resetAfterSec = Math.ceil(resetAfterMs / 1000); |