Skip to main content

IQRateLimiter

@quik/http


@quik/http / IQRateLimiter

Interface: IQRateLimiter

Defined in: http/src/router/QRateLimiter.ts:6

Contract for a rate-limiting backend.

Methods​

check()​

check(key, max, windowMs): Promise<{ allowed: boolean; remaining: number; resetMs: number; }>

Defined in: http/src/router/QRateLimiter.ts:15

Check whether the given key is allowed to proceed. Increments the counter for the key and returns whether the request is within the limit.

Parameters​

key​

string

Unique client identifier (e.g. IP address).

max​

number

Maximum allowed requests per window.

windowMs​

number

Duration of the rate-limit window in milliseconds.

Returns​

Promise<{ allowed: boolean; remaining: number; resetMs: number; }>


clear()​

clear(): void

Defined in: http/src/router/QRateLimiter.ts:20

Reset all counters (used during testing or on reset).

Returns​

void