Skip to main content

Function: RateLimit()

RateLimit(options?): (target, propertyKey?, descriptor?) => void

Defined in: service-core/src/decorators/RouteDecorators.ts:352

Indicates that the endpoint should have rate limiting applied for all incoming requests. This can be applied at the endpoint function level or the route class level. When applying at the class level, all defined endpoints in the class will have rate limiting applied.

Optionally pass in options to control the identifier of the rate limit. Set options.id to set an explicit identifier. By default, the method and the percent-decoded, normalized path of the request (without the query portion) is used as the identifier. Set the options.perUser option to true to have the limit scoped to each user individually; anonymous callers are then scoped by client IP address (see trusted_proxies). Calling @RateLimit() with no options enables perUser. See RouteUtils.checkRateLimiter().

Parameters​

options?​

RateLimitOptions = ...

Returns​

(target, propertyKey?, descriptor?) => void