Skip to content

Commit 74b5299

Browse files
committed
feat(RateLimiter): add reset() method to clear rate limit state for a given IP
1 parent 35fb17e commit 74b5299

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/rate-limit.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ export class RateLimiter {
4646
this.cache.set(ip, current + 1, this.windowMs);
4747
return true;
4848
}
49+
/**
50+
* Resets the request count for a given IP address.
51+
*
52+
* Useful for clearing rate limit state after a successful
53+
* authentication or admin action.
54+
*
55+
* @param ip - The IP address to reset.
56+
*
57+
* @example
58+
* rateLimiter.reset("192.168.1.1");
59+
*/
60+
reset(ip: string): void {
61+
this.cache.delete(ip);
62+
}
4963
}
5064

5165
// Global instance for track-user endpoint (5 requests per IP per minute)

0 commit comments

Comments
 (0)