Skip to main content

RateLimit

@quik/http


@quik/http / Decorators / RateLimit

Function: RateLimit()

RateLimit(options): <This, Args, Return>(target, context) => MethodDecoratorType<This, Args, Return>

Defined in: http/src/router/decorators/RateLimit.ts:30

Decorator that enforces a rate limit on an endpoint. Uses the client IP address as the key. When the limit is exceeded, a TooManyRequestsError is thrown.

Parameters

options

RateLimitOptions

Rate-limit configuration.

Returns

<This, Args, Return>(target, context) => MethodDecoratorType<This, Args, Return>

Example

@RateLimit({ max: 10, windowMs: 60_000 })
@Get("/search")
async search(event: IQEvent) { ... }