@rtorcato/api-rate-limit v1.0.0
Interfaces
RateLimiterOptions
Defined in: index.ts:1
Properties
requests
requests:
number
Defined in: index.ts:3
Max requests allowed per key within the window.
windowMs
windowMs:
number
Defined in: index.ts:5
Sliding window size in milliseconds.
RateLimitResult
Defined in: index.ts:8
Properties
allowed
allowed:
boolean
Defined in: index.ts:9
remaining
remaining:
number
Defined in: index.ts:11
Requests remaining in the current window (0 when blocked).
RateLimiter
Defined in: index.ts:14
Properties
check
check: (
key) =>RateLimitResult
Defined in: index.ts:16
Record a hit for key and report whether it is within the limit.
Parameters
key
string
Returns
reset
reset: () =>
void
Defined in: index.ts:18
Drop all tracked keys (handy for tests and manual resets).
Returns
void
Functions
createRateLimiter()
createRateLimiter(
__namedParameters):RateLimiter
Defined in: index.ts:34
Create an in-memory sliding-window rate limiter.
Framework-agnostic — call check(key) from any handler and react to the
result. Wrap it for Hono/Express in a dedicated adapter package.
ponytail: in-memory, single-process only. Swap the Map for a shared store (e.g. Redis) behind the same interface if you need limits across instances.