Fix a sliding-window IP rate limiter that never expires old timestamps and extends lockouts on blocked requests.
Our in-memory rate limiter should allow 5 requests per 60 seconds per IP. It works for the first minute, then permanently blocks legitimate users forever. Fix isAllowed(ip, now).
timestamps.push(now) runs unconditionally even when the request is rejected.timestamps to keep only entries within the active window (ts > now - 60000), check recent.length >= 5 FIRST (updating the map and returning false without pushing now), and only push now when allowed.Ready to run test suite
Edit the code above and press Cmd/Ctrl + Enter or click Run Tests.