ThrottlerOptions


interface ThrottlerOptions {
  name?: string
  limit: Resolvable<number>
  ttl: Resolvable<number>
  blockDuration?: Resolvable<number>
  ignoreUserAgents?: RegExp[]
  skipIf?: (context: ExecutionContext) => boolean
  getTracker?: ThrottlerGetTrackerFunction
  generateKey?: ThrottlerGenerateKeyFunction
}

Properties

Property Description
name?: string

The name for the rate limit to be used. This can be left blank and it will be tracked as "default" internally. If this is set, it will be added to the return headers. e.g. x-ratelimit-remaining-long: 5

limit: Resolvable<number>

The amount of requests that are allowed within the ttl's time window.

ttl: Resolvable<number>

The number of milliseconds the limit of requests are allowed

blockDuration?: Resolvable<number>

The number of milliseconds the request will be blocked.

ignoreUserAgents?: RegExp[]

The user agents that should be ignored (checked against the User-Agent header).

skipIf?: (context: ExecutionContext) => boolean

A factory method to determine if throttling should be skipped. This can be based on the incoming context, or something like an env value.

getTracker?: ThrottlerGetTrackerFunction

A method to override the default tracker string.

generateKey?: ThrottlerGenerateKeyFunction

A method to override the default key generator.