API Reference / modelence / server / consumeRateLimit

consumeRateLimit(options): Promise<void>

Defined in: src/rate-limit/rules.ts:29

This function will check all rate limit rules on the specified bucket and type, throw an error if any of them are exceeded and increase the count of the rate limit record.

Example

await consumeRateLimit({ bucket: 'api', type: 'ip', value: '127.0.0.1' });

Parameters

ParameterTypeDescription
options{ bucket: string; type: RateLimitType; value: string; }-
options.bucketstringThe bucket for the rate limit.
options.typeRateLimitTypeThe type of the rate limit.
options.valuestringThe value for the rate limit.

Returns

Promise<void>