Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.modelence.com/llms.txt

Use this file to discover all available pages before exploring further.

API Reference / modelence / server / consumeRateLimit
consumeRateLimit(options): Promise<void>
Defined in: packages/modelence/src/rate-limit/rules.ts:30 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; message?: string; type: RateLimitType; value: string; }-
options.bucketstringThe bucket for the rate limit.
options.message?stringOptional custom error message when the rate limit is exceeded.
options.typeRateLimitTypeThe type of the rate limit.
options.valuestringThe value for the rate limit.

Returns

Promise<void>