Skip to main content

Interface: IRateLimitStore

Defined in: rate-limit.ts:85 Pluggable backend for rate-limit state. Implementations decide how counters are stored and how concurrency is resolved (in-memory, Redis, distributed log, …). Stores are designed to be reused across multiple (windowMs, maxRequests) configurations keyed by the caller’s key (typically userId, ip, or route + clientId).

Methods

check()

check(key, windowMs, maxRequests): Promise<&#123; limited: boolean; remaining: number; resetTime: number; total: number; &#125;>
Defined in: rate-limit.ts:95 Atomically increment the counter for key within a sliding window of windowMs and decide whether to allow the request.

Parameters

key
string Caller-chosen identity key (e.g. "user:42").
windowMs
number Window length in milliseconds.
maxRequests
number Maximum requests permitted in the window.

Returns

Promise<&#123; limited: boolean; remaining: number; resetTime: number; total: number; &#125;> A RateLimitCheckResult describing the decision.

reset()

reset(key): Promise<void>
Defined in: rate-limit.ts:100 Drop any state held for key. Useful for admin / unit-test reset paths; not invoked by middleware itself.

Parameters

key
string

Returns

Promise<void>