Options
All
  • Public
  • Public/Protected
  • All
Menu

Perform HTTP throttled requests with a tokenbucket implementation. All requests that exceed the tokenbucket limit will be dropped.

since

0.0.1

Hierarchy

Index

Constructors

constructor

  • new APIRequester(maxTokens: number, tokensRefillRateInMs: number): APIRequester

Properties

Private _httpClient

_httpClient: AxiosInstance

lastTokenRefill

lastTokenRefill: Date

When the tokenbucket was last refilled

readonly

maxTokens

maxTokens: number

tokens

tokens: number

Amount of tokens left

readonly

tokensRefillRateInMs

tokensRefillRateInMs: number

Methods

performRequest

  • performRequest(options: AxiosRequestConfig): Promise<AxiosResponse<any>>

refillTokens

  • refillTokens(): boolean
  • Refills the tokenbucket if it was has not already been filled during the current timeframe

    since

    0.0.1

    method

    refillTokens

    Returns boolean

requestIsAllowed

  • requestIsAllowed(): boolean

Generated using TypeDoc