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()?
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()
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
| Parameter | Type | Description |
|---|---|---|
key | string | Rate limit key (e.g., user ID) |
windowMs | number | Time window in milliseconds |
Returns
| RateLimitEntry | Promise<RateLimitEntry>
Current count and time until window resets (in ms)
record()
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
| Parameter | Type | Description |
|---|---|---|
key | string | Rate limit key |
Returns
void | Promise<void>