Rate limiting (sliding window, fail-closed)
Generated from
mcp/patterns.registry.json— do not edit by hand; change the registry and runbun run patterns:build.
Index card — the docs below are the canonical explanation; deep-tier pattern pages additionally carry invariants and emulation notes.
Category: Anti-Abuse · Tier: light · Risk: medium — throttling correctness affects both abuse defense and legitimate-user access
A sliding-window rate limiter factory backed by Upstash Redis that produces per-purpose limiters (email, IP, comments, grants) and fails closed when Redis is unavailable.
When to use: Use whenever an endpoint or action needs abuse-resistant request throttling with predictable fail-closed behavior.
Docs
Code
src/lib/server/abuse/rate-limit/(GitHub · GitLab)src/lib/server/api/rate-limit.ts(GitHub · GitLab)
Proof
Machine-readable record: anti-abuse-rate-limiting in mcp/patterns.registry.json.