Pular para o conteúdo
Português (BR)

RateLimitOptionsType

Este conteúdo não está disponível em sua língua ainda.

RateLimitOptionsType = object

Defined in: src/http/cache/RateLimitOptions.ts:22

Plain options-object shape accepted by rateLimit.

readonly cache: Cache

Defined in: src/http/cache/RateLimitOptions.ts:24

Backing cache. Should be a shared/distributed one (Redis) in prod.


readonly key: (request) => string | Promise<string>

Defined in: src/http/cache/RateLimitOptions.ts:30

Identity function — typically derives from IP, user id, or API key.

HttpRequest

string | Promise<string>


readonly optional keyPrefix?: 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.


readonly max: number

Defined in: src/http/cache/RateLimitOptions.ts:28

Maximum requests allowed per window per key.


readonly optional onLimit?: (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).

RateLimitContext

HttpResponse


readonly windowMs: number

Defined in: src/http/cache/RateLimitOptions.ts:26

Length of the rolling window in milliseconds.