RateLimitOptionsType
此内容尚不支持你的语言。
RateLimitOptionsType =
object
Defined in: src/http/cache/RateLimitOptions.ts:22
Plain options-object shape accepted by rateLimit.
Properties
Section titled “Properties”
readonlycache:Cache
Defined in: src/http/cache/RateLimitOptions.ts:24
Backing cache. Should be a shared/distributed one (Redis) in prod.
readonlykey: (request) =>string|Promise<string>
Defined in: src/http/cache/RateLimitOptions.ts:30
Identity function — typically derives from IP, user id, or API key.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”string | Promise<string>
keyPrefix?
Section titled “keyPrefix?”
readonlyoptionalkeyPrefix?:string
Defined in: src/http/cache/RateLimitOptions.ts:35
Cache-key namespace prepended to the user key. Defaults to
'rl:' so multiple rate-limiters in the same cache don’t collide.
readonlymax:number
Defined in: src/http/cache/RateLimitOptions.ts:28
Maximum requests allowed per window per key.
onLimit?
Section titled “onLimit?”
readonlyoptionalonLimit?: (context) =>HttpResponse
Defined in: src/http/cache/RateLimitOptions.ts:41
Custom 429 response builder. Receives the limit context for
full control over the body / headers. Default: a plain 429 with
Retry-After (seconds-rounded-up).
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”windowMs
Section titled “windowMs”
readonlywindowMs:number
Defined in: src/http/cache/RateLimitOptions.ts:26
Length of the rolling window in milliseconds.
