Deno KV Rate Limit
A sliding-window rate limiter middleware for Deno.serve backed by Deno KV, so the limit holds across isolates and regions on Deploy rather than in one process memory. rateLimit({ limit, windowMs })(handler) wraps a handler and enforces a per-client window using the two-bucket weighted approximation, where each increment is kv.atomic().mutate({ type: sum, expireIn }) so the counter buckets self-garbage-collect on their own TTL with no sweeper. Emits the IETF draft RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and RateLimit-Policy headers plus Retry-After on a 429. Zero dependencies.
npx shadcn@latest add https://ui.aryank.space/r/deno-kv-rate-limit.jsonInstalls from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.
Under steady traffic the sliding window refills as fast as it drains; every request passes and the budget hovers, consistent across isolates and regions.