DecoupledRouterClient
Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:17
Decoupled Router Client class provides functionality specific to the decoupled-router module.
- ApiClientOptions
- BaseUrl
Extends
Section titled “Extends”ApiClient
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DecoupledRouterClient(baseUrl, options?): DecoupledRouterClient;Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:23
Creates a new instance of the DecoupledRouterClient.
Parameters
Section titled “Parameters”baseUrl
Section titled “baseUrl”string
The base URL of the API. BaseUrl
options?
Section titled “options?”ApiClientOptions
(Optional) Additional options for configuring the API client. ApiClientOptions
Returns
Section titled “Returns”DecoupledRouterClient
Overrides
Section titled “Overrides”ApiClient.constructorProperties
Section titled “Properties”apiPrefix
Section titled “apiPrefix”apiPrefix: string | undefined;Defined in: api-client/dist/index.d.mts:216
Inherited from
Section titled “Inherited from”ApiClient.apiPrefixauthentication
Section titled “authentication”authentication: Authentication | undefined;Defined in: api-client/dist/index.d.mts:224
ApiClientOptions.authentication
Inherited from
Section titled “Inherited from”ApiClient.authenticationbaseUrl
Section titled “baseUrl”baseUrl: string;Defined in: api-client/dist/index.d.mts:212
BaseUrl
Inherited from
Section titled “Inherited from”ApiClient.baseUrlcache: Cache | undefined;Defined in: api-client/dist/index.d.mts:232
Inherited from
Section titled “Inherited from”ApiClient.cachecustomFetch
Section titled “customFetch”customFetch: | ((input, init?) => Promise<Response>) | undefined;Defined in: api-client/dist/index.d.mts:220
Inherited from
Section titled “Inherited from”ApiClient.customFetchdebug: boolean | undefined;Defined in: api-client/dist/index.d.mts:244
Inherited from
Section titled “Inherited from”ApiClient.debugdefaultLocale
Section titled “defaultLocale”defaultLocale: string | undefined;Defined in: api-client/dist/index.d.mts:228
ApiClientOptions.defaultLocale
Inherited from
Section titled “Inherited from”ApiClient.defaultLocalelogger
Section titled “logger”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
Inherited from
Section titled “Inherited from”ApiClient.loggerserializer
Section titled “serializer”serializer: Serializer | undefined;Defined in: api-client/dist/index.d.mts:236
Inherited from
Section titled “Inherited from”ApiClient.serializerMethods
Section titled “Methods”addAuthorizationHeader()
Section titled “addAuthorizationHeader()”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.
Parameters
Section titled “Parameters”options
Section titled “options”RequestInit | undefined
The RequestInit options to which the authorization header should be added.
Returns
Section titled “Returns”Promise<RequestInit>
The updated RequestInit options with the authorization header, if applicable.
Inherited from
Section titled “Inherited from”ApiClient.addAuthorizationHeadercreateURL()
Section titled “createURL()”createURL(__namedParameters): string;Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:90
Generates an endpoint URL based on the provided parameters.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”localeSegment?
Section titled “localeSegment?”string
string
Returns
Section titled “Returns”string
The endpoint URL as a string.
Params
Section titled “Params”params - The parameters to use for creating the URL.
fetch()
Section titled “fetch()”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
Parameters
Section titled “Parameters”URL | RequestInfo
RequestInfo
RequestInit
RequestInit
Returns
Section titled “Returns”Promise<FetchReturn>
a response wrapped in a promise
Inherited from
Section titled “Inherited from”ApiClient.fetchgetAccessToken()
Section titled “getAccessToken()”protected getAccessToken(__namedParameters): Promise<OAuthTokenResponse>;Defined in: api-client/dist/index.d.mts:262
Fetch the OAuth token from the BaseUrl
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”OAuthCredentials
Returns
Section titled “Returns”Promise<OAuthTokenResponse>
Params
Section titled “Params”params - The credentials for getting an OAuth token. OAuthCredentials
Inherited from
Section titled “Inherited from”ApiClient.getAccessTokengetCachedResponse()
Section titled “getCachedResponse()”getCachedResponse<T>(cacheKey): Promise< | NonNullable<Awaited<T>>| null>;Defined in: api-client/dist/index.d.mts:286
Retrieves a cached response from the cache.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”cacheKey
Section titled “cacheKey”string
The cache key to use for retrieving the cached response.
Returns
Section titled “Returns”Promise<
| NonNullable<Awaited<T>>
| null>
A promise wrapping the cached response as a generic type.
Inherited from
Section titled “Inherited from”ApiClient.getCachedResponselog(level, message): void;Defined in: api-client/dist/index.d.mts:280
Calls the appropriate logger method based on level
Parameters
Section titled “Parameters”LogLevels
level based on npm log levels
message
Section titled “message”string
the message to log
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ApiClient.logtranslatePath()
Section titled “translatePath()”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.
Parameters
Section titled “Parameters”string
the path to translate
options?
Section titled “options?”Returns
Section titled “Returns”Promise<
| DecoupledRouterResponse
| RawDecoupledRouterResponse>
A Promise that resolves to the JSON data provided by the router.
createCacheKey()
Section titled “createCacheKey()”static createCacheKey(__namedParameters): string;Defined in: decoupled-router-client/src/DecoupledRouterClient.ts:112
Generates a cache key based on the provided parameters.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”cacheKey?
Section titled “cacheKey?”string
localeSegment?
Section titled “localeSegment?”string
string
Returns
Section titled “Returns”string
The generated cache key as a string.
Params
Section titled “Params”params - The parameters to use for generating the cache key.
Example
Section titled “Example”const key1 = await this.createCacheKey('en', '/articles/give-your-oatmeal-the-ultimate-makeover');// key1: 'en--/articles/give-your-oatmeal-the-ultimate-makeover'