@rtorcato/api-rate-limit-hono
v2.0.0
Published
Hono middleware for @rtorcato/api-rate-limit (sliding-window rate limiter).
Downloads
229
Maintainers
Readme
@rtorcato/api-rate-limit-hono
Hono middleware for @rtorcato/api-rate-limit — sliding-window rate limiter.
Install
pnpm add @rtorcato/api-rate-limit @rtorcato/api-rate-limit-honohono is a peer dependency — you bring your own version.
Usage
Pass a store — memoryStore() for a single process, or redisStore() from
@rtorcato/api-rate-limit-redis
to share limits across instances.
import { memoryStore } from '@rtorcato/api-rate-limit'
import { rateLimitMiddleware } from '@rtorcato/api-rate-limit-hono'
app.use(rateLimitMiddleware({ requests: 100, windowMs: 60_000, store: memoryStore() }))Responds 429 with the standard error envelope { error: 'TooManyRequestsError', code: 'too_many_requests', message } when the limit is exceeded. Keys on X-Forwarded-For → X-Real-IP.
Related
@rtorcato/api-rate-limit— framework-agnostic core (stores, sliding window)@rtorcato/api-rate-limit-redis— Redis store for limits shared across instances@rtorcato/api-rate-limit-express— Express adapter
Source: https://github.com/rtorcato/api-common/tree/main/packages/api-rate-limit-hono
