Overview
What this package owns in the runtime
Throttler integrates rate limiting into the xtask route pipeline. It limits requests per time window using configurable storage backends, supports custom key generators for IP, user, or API-key-based identification, and applies limits globally or per-method through decorators.
What it provides
- configureThrottler() sets global defaults with memory or Redis driver, TTL, and request limit.
- @Throttle(limit, ttl) decorator applies per-endpoint limits overriding global defaults.
- keyGenerator option accepts request and context to compute any throttle key (IP, user ID, API key).
- TTL format supports 500ms, 30s, 5m, 1h, 1d shorthand strings.
How it fits
- Initialized automatically by @xtaskjs/core when the package is installed and configureThrottler() has been called.
- Applies before controller handlers so rate checking runs consistently regardless of framework adapter.
- Demonstrated by the 24-throttler_app sample with global and per-endpoint throttle policies.