* Periodically clean up stale entries.
()
| 52 | * Periodically clean up stale entries. |
| 53 | */ |
| 54 | cleanup(): void { |
| 55 | const now = Date.now(); |
| 56 | for (const [ip, timestamps] of this.attempts) { |
| 57 | const recent = timestamps.filter((t) => now - t < this.windowMs); |
| 58 | if (recent.length === 0) { |
| 59 | this.attempts.delete(ip); |
| 60 | } else { |
| 61 | this.attempts.set(ip, recent); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |