Decoupled Router Client class provides functionality specific to the decoupled-router module.

See

  • ApiClientOptions
  • BaseUrl

Hierarchy

  • ApiClient
    • DecoupledRouterClient

Constructors

  • Creates a new instance of the DecoupledRouterClient.

    Parameters

    • baseUrl: string

      The base URL of the API. BaseUrl

    • Optional options: ApiClientOptions

      (Optional) Additional options for configuring the API client. ApiClientOptions

    Returns DecoupledRouterClient

Properties

#private: any
apiPrefix: undefined | string

ApiClientOptions.apiPrefix

authentication: undefined | Authentication

ApiClientOptions.authentication

baseUrl: string

BaseUrl

cache: undefined | Cache

ApiClientOptions.cache

customFetch: undefined | ((input, init?) => Promise<Response>)

ApiClientOptions.customFetch

Type declaration

debug: undefined | boolean

ApiClientOptions.debug

defaultLocale: undefined | string

ApiClientOptions.defaultLocale

logger: undefined | {
    debug: undefined | LogMethod;
    error: undefined | LogMethod;
    http: undefined | LogMethod;
    info: undefined | LogMethod;
    silly: undefined | LogMethod;
    verbose: undefined | LogMethod;
    warn: undefined | LogMethod;
}

ApiClientOptions.logger

Type declaration

  • debug: undefined | LogMethod
  • error: undefined | LogMethod
  • http: undefined | LogMethod
  • info: undefined | LogMethod
  • silly: undefined | LogMethod
  • verbose: undefined | LogMethod
  • warn: undefined | LogMethod
serializer: undefined | Serializer

ApiClientOptions.serializer

Methods

  • Adds an authorization header to the provided RequestInit options if authentication of type "Basic" is configured. If the authentication type is "OAuth", it will fetch a new access token or use the stored access token if it exists and is still valid. if the authentication type is "Custom", it will use the provided value.

    Parameters

    • options: undefined | RequestInit

      The RequestInit options to which the authorization header should be added.

    Returns Promise<RequestInit>

    The updated RequestInit options with the authorization header, if applicable.

  • Generates an endpoint URL based on the provided parameters.

    Parameters

    • __namedParameters: {
          localeSegment?: string;
          path: string;
      }
      • Optional localeSegment?: string
      • path: string

    Returns string

    The endpoint URL as a string.

    Params

    params - The parameters to use for creating the URL.

  • Uses customFetch if it is set, otherwise uses the default fetch

    Parameters

    • input: RequestInfo | URL

      RequestInfo

    • Optional init: RequestInit

      RequestInit

    Returns Promise<FetchReturn>

    a response wrapped in a promise

  • Fetch the OAuth token from the BaseUrl

    Parameters

    • __namedParameters: {
          clientId: string;
          clientSecret: string;
      }
      • clientId: string
      • clientSecret: string

    Returns Promise<OAuthTokenResponse>

    Param0

    the Client ID

    Param1

    the Client secret

  • Retrieves a cached response from the cache.

    Type Parameters

    • T

    Parameters

    • cacheKey: string

      The cache key to use for retrieving the cached response.

    Returns Promise<null | NonNullable<Awaited<T>>>

    A promise wrapping the cached response as a generic type.

  • Calls the appropriate logger method based on level

    Parameters

    • level: LogLevels

      level based on npm log levels

    • message: string

      the message to log

    Returns void

  • Generates a cache key based on the provided parameters.

    Parameters

    • __namedParameters: {
          localeSegment?: string;
          path: string;
      }
      • Optional localeSegment?: string
      • path: string

    Returns string

    The generated cache key as a string.

    Params

    params - The parameters to use for generating the cache key.

    Example

    const key1 = await this.createCacheKey('en', '/articles/give-your-oatmeal-the-ultimate-makeover');
    // key1: 'en--/articles/give-your-oatmeal-the-ultimate-makeover'

Generated using TypeDoc