Skip to content

DecoupledRouterClient

Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:17

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

  • ApiClientOptions
  • BaseUrl
  • ApiClient
new DecoupledRouterClient(baseUrl, options?): DecoupledRouterClient;

Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:23

Creates a new instance of the DecoupledRouterClient.

string

The base URL of the API. BaseUrl

ApiClientOptions

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

DecoupledRouterClient

ApiClient.constructor
apiPrefix: string | undefined;

Defined in: api-client/dist/index.d.mts:216

ApiClientOptions.apiPrefix

ApiClient.apiPrefix

authentication: Authentication | undefined;

Defined in: api-client/dist/index.d.mts:224

ApiClientOptions.authentication

ApiClient.authentication

baseUrl: string;

Defined in: api-client/dist/index.d.mts:212

BaseUrl

ApiClient.baseUrl

cache: Cache | undefined;

Defined in: api-client/dist/index.d.mts:232

ApiClientOptions.cache

ApiClient.cache

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

Defined in: api-client/dist/index.d.mts:220

ApiClientOptions.customFetch

ApiClient.customFetch

debug: boolean | undefined;

Defined in: api-client/dist/index.d.mts:244

ApiClientOptions.debug

ApiClient.debug

defaultLocale: string | undefined;

Defined in: api-client/dist/index.d.mts:228

ApiClientOptions.defaultLocale

ApiClient.defaultLocale

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

Defined in: api-client/dist/index.d.mts:240

ApiClientOptions.logger

ApiClient.logger

serializer: Serializer | undefined;

Defined in: api-client/dist/index.d.mts:236

ApiClientOptions.serializer

ApiClient.serializer
addAuthorizationHeader(options): Promise<RequestInit>;

Defined in: api-client/dist/index.d.mts:274

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.

RequestInit | undefined

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

Promise<RequestInit>

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

ApiClient.addAuthorizationHeader

createURL(__namedParameters): string;

Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:90

Generates an endpoint URL based on the provided parameters.

string

string

string

The endpoint URL as a string.

params - The parameters to use for creating the URL.


fetch(input, init?): Promise<FetchReturn>;

Defined in: api-client/dist/index.d.mts:257

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

URL | RequestInfo

RequestInfo

RequestInit

RequestInit

Promise<FetchReturn>

a response wrapped in a promise

ApiClient.fetch

protected getAccessToken(__namedParameters): Promise<OAuthTokenResponse>;

Defined in: api-client/dist/index.d.mts:262

Fetch the OAuth token from the BaseUrl

OAuthCredentials

Promise<OAuthTokenResponse>

params - The credentials for getting an OAuth token. OAuthCredentials

ApiClient.getAccessToken

getCachedResponse<T>(cacheKey): Promise<
| NonNullable<Awaited<T>>
| null>;

Defined in: api-client/dist/index.d.mts:286

Retrieves a cached response from the cache.

T

string

The cache key to use for retrieving the cached response.

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

A promise wrapping the cached response as a generic type.

ApiClient.getCachedResponse

log(level, message): void;

Defined in: api-client/dist/index.d.mts:280

Calls the appropriate logger method based on level

LogLevels

level based on npm log levels

string

the message to log

void

ApiClient.log

translatePath(path, options?): Promise<
| DecoupledRouterResponse
| RawDecoupledRouterResponse>;

Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:34

Translates a path in the consuming application to a Drupal entity.

string

the path to translate

GetOptions

Promise< | DecoupledRouterResponse | RawDecoupledRouterResponse>

A Promise that resolves to the JSON data provided by the router.


static createCacheKey(__namedParameters): string;

Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:112

Generates a cache key based on the provided parameters.

string

string

string

string

The generated cache key as a string.

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

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