Instance state type
Headers type
Params type
Instance state type
Headers type
Params type
Get the adapter (if configured).
Whether the policy is initialized and enabled.
Get the onRateLimit callback from config.
Clear the rules cache.
Call this if you need to force re-computation of rules, though typically this is not needed.
ProtectedcomputeCompute rule configuration for a method+path combination.
This is the expensive O(n) operation that gets memoized. Finds matching rule and merges with policy defaults.
HTTP method (uppercase)
Request path
Computed rule or null if disabled
ProtectedgetGet the default HTTP methods for rate limiting.
ProtectedgetGet the default serializer for rate limiting.
Get or create a rate limiter for the given key.
Initialize the rate limit policy with configuration.
Optionalconfig: boolean | RateLimitConfig<S, H, P>ProtectedmergeMerge a matched rule with policy defaults.
Resolve policy configuration for a specific request.
Uses memoization for rule matching (O(n) only once per method+path). Skip callbacks are always evaluated since they depend on request context.
HTTP method (uppercase)
Request path
Full request context for skip callback
OptionalskipCallback: (ctx: RequestKeyOptions<S, H, P>) => boolean | undefinedOptional skip callback from config
Resolved rule or null if disabled
Resolve rate limit configuration for a request.
Rate limit policy for controlling request rate.
Uses token bucket algorithm to enforce rate limits. Each unique key (generated by the serializer) gets its own bucket, allowing per-endpoint or per-user rate limiting.
Uses endpoint-scoped serialization by default (method + path), meaning all requests to the same endpoint share a rate limit bucket regardless of their parameters or payload.