import { Context, MiddlewareOptions, Middleware } from '@orpc/server'; import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard'; import { b as RateLimitResult, R as RateLimiter } from './shared/ratelimit.BtcMexUf.mjs'; export { a as RateLimitOptions } from './shared/ratelimit.BtcMexUf.mjs'; import { Value, Promisable } from '@orpc/shared'; declare const RATELIMIT_HANDLER_PLUGIN_CONTEXT_SYMBOL: unique symbol; interface RateLimitHandlerPluginContext { [RATELIMIT_HANDLER_PLUGIN_CONTEXT_SYMBOL]?: { /** * The result of the ratelimiter after applying limits */ results: RateLimitResult[]; }; } /** * Automatically adds HTTP rate-limiting headers (RateLimit-* and Retry-After) to responses * when used with middleware created by createRatelimitMiddleware. * * @see {@link https://orpc.dev/docs/helpers/ratelimit#handler-plugin Ratelimit handler plugin} */ declare class RateLimitHandlerPlugin implements StandardHandlerPlugin { name: string; init(options: StandardHandlerOptions): StandardHandlerOptions; } declare const RATELIMIT_MIDDLEWARE_CONTEXT_SYMBOL: unique symbol; interface RateLimitMiddlewareContext { [RATELIMIT_MIDDLEWARE_CONTEXT_SYMBOL]?: { /** * The applied limits in this request, mainly for deduplication purposes */ applied: { limiter: RateLimiter; key: string; }[]; }; } interface RateLimitMiddlewareOptions { /** * The rule set to use for rate limiting */ limiter: Value, [options: MiddlewareOptions>, input: TInput]>; /** * The key to identify the user/requester */ key: Value, [options: MiddlewareOptions>, input: TInput]>; /** * The weight of the request. Determines how many tokens or quota * units are consumed by this request. Must be an integer greater than 0. * * @default 1 */ weight?: Value, [options: MiddlewareOptions>, input: TInput]>; /** * If your ratelimit middleware is used multiple times * or you invoke a procedure inside another procedure (shared the same context) that also has * ratelimit middleware **with the same limiter and key**, this option * will ensure that the limit is only applied once per request. * * @default true */ dedupe?: boolean; } /** * Creates a middleware that enforces rate limits in oRPC procedures. * Supports per-request deduplication and integrates with the ratelimit handler plugin. * * @see {@link https://orpc.dev/docs/helpers/ratelimit#createratelimitmiddleware Ratelimit middleware} */ declare function ratelimit({ dedupe, ...options }: RateLimitMiddlewareOptions): Middleware; export { RATELIMIT_HANDLER_PLUGIN_CONTEXT_SYMBOL, RATELIMIT_MIDDLEWARE_CONTEXT_SYMBOL, RateLimitHandlerPlugin, RateLimitResult, RateLimiter, ratelimit }; export type { RateLimitHandlerPluginContext, RateLimitMiddlewareContext, RateLimitMiddlewareOptions };