API Reference
Express helpers for @g14o/ratelimit.
CreateRateLimitOptions
| Option | Type | Description |
|---|---|---|
env? | | Environment name override. When omitted, falls back to Values |
inMemoryDuringBuild? | | When true |
hooks? | | Optional lifecycle hooks for observability and side effects. Hooks are awaited; hook errors are logged and swallowed so they never affect rate limiting or fail-open behavior. |
logger? | | Application logger. Defaults to a silent no-op logger. |
skipRateLimit? | | When |
tiers? | | Override built-in tier limits/windows/prefixes. Each tier key is optional; each field inside a tier is optional and merged onto factory defaults. |
redis? | | Legacy Upstash credentials or client. Mutually exclusive with |
store? | | Explicit store implementation (preferred). |
ExpressRateLimitClient
| Prop | Type | Description |
|---|---|---|
checkRateLimit | | Checks the rate limit for an Express request without wrapping a handler. |
getRateLimiter | | Returns a cached rate limiter adapter for a tier. |
middleware | | Express middleware that rate-limits before Sends |
reset | | Clears in-memory limiter state and the adapter cache. Useful in tests; does not reset Upstash Redis counters. |
userMiddleware | | Express middleware with per-user rate limiting. Uses |
withRateLimit | | Wraps an Express route handler with rate limiting. Sends |
withUserRateLimit | | Wraps an Express route handler with per-user rate limiting. |
ExpressRateLimitOptions
| Option | Type | Description |
|---|---|---|
identifierFn? | | Function to get the identifier for the request. Defaults to the IP address of the request. |
prefix? | | Redis key prefix override for this call. Defaults to the tier prefix. |
skipRateLimit? | | Skip rate limit for this request. |
tier? | | Rate limit tier to use. Defaults to |