Skip to content

Interface: RateLimitStore

Defined in: packages/core/src/core/middleware/RateLimiter.ts:38

Store interface for rate limiting state.

Implement this interface for distributed rate limiting (e.g., Redis, Valkey, Memcached).

Methods

destroy()?

ts
optional destroy(): void;

Defined in: packages/core/src/core/middleware/RateLimiter.ts:63

Clean up resources (intervals, connections). Called when the server shuts down.

Returns

void


increment()

ts
increment(key, windowMs): 
  | RateLimitEntry
| Promise<RateLimitEntry>;

Defined in: packages/core/src/core/middleware/RateLimiter.ts:48

Check the current request count for a key within a time window. Does NOT record the request — call record() separately after confirming the request is under the limit.

Parameters

ParameterTypeDescription
keystringRate limit key (e.g., user ID)
windowMsnumberTime window in milliseconds

Returns

| RateLimitEntry | Promise<RateLimitEntry>

Current count and time until window resets (in ms)


record()

ts
record(key): void | Promise<void>;

Defined in: packages/core/src/core/middleware/RateLimiter.ts:57

Record a successful (non-rejected) request. Called ONLY when the request is under the limit. This separation prevents rejected requests from inflating the window.

Parameters

ParameterTypeDescription
keystringRate limit key

Returns

void | Promise<void>