Skip to content

Commit 2d62598

Browse files
committed
fix: rate limit not returning status true if timestamps is over the limit
1 parent 6f529e5 commit 2d62598

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/components/utils/rateLimiter.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ export async function rateLimiter(
6161
);
6262
}
6363

64+
if (isStillBlocked || entry.timestamps.length >= LIMIT) {
65+
entry = await penalizeUser(lid, entry);
66+
67+
return {
68+
value: entry,
69+
status: true,
70+
overLimit: entry.timestamps.length >= LIMIT,
71+
};
72+
}
73+
6474
entry.timestamps.push(now);
6575
await redis.set(key, JSON.stringify(entry));
6676

0 commit comments

Comments
 (0)