Documentation / zerotal / index / ThrottleOptions
Interface: ThrottleOptions
Defined in: packages/core/src/middleware/ThrottleMiddleware.ts:13
Properties
maxAttempts
maxAttempts:
number
Defined in: packages/core/src/middleware/ThrottleMiddleware.ts:15
Maximum number of requests allowed within the window.
windowSeconds?
optionalwindowSeconds?:number
Defined in: packages/core/src/middleware/ThrottleMiddleware.ts:17
Time window in seconds. Defaults to 60.
keyResolver?
optionalkeyResolver?: (ctx) =>string
Defined in: packages/core/src/middleware/ThrottleMiddleware.ts:22
Custom key resolver — defaults to client IP address. Use this to rate-limit by user ID, API key, route, etc.
Parameters
ctx
Returns
string
trustedProxies?
optionaltrustedProxies?:number
Defined in: packages/core/src/middleware/ThrottleMiddleware.ts:38
Number of trusted reverse proxies in front of this server.
X-Forwarded-For is client-writable, so it is only consulted when you state how many
proxies sit in front of the app — the count is what says which entry is not
attacker-controlled. Without it the unspoofable socket address is used.
undefined(default) /0— no trusted proxy; key on the socket address1— one trusted proxy; the client IP is the second-to-last XFF entryn— the client IP isnentries from the right
Example
// Behind one load balancer:
ThrottleMiddleware.with({ maxAttempts: 60, trustedProxies: 1 })