@appsemble/node-utils
Version:
NodeJS utilities used by Appsemble internally.
42 lines (41 loc) • 1.45 kB
TypeScript
import { type AxiosResponse, type InternalAxiosRequestConfig } from 'axios';
/**
* This is used to set a request id, so the request and response can be matched in the logs.
*/
declare const id: unique symbol;
declare module 'axios' {
interface AxiosRequestConfig {
[id]?: number;
}
}
/**
* An {@link axios} request interceptor to add support for {@link form-data}.
*
* @param config The axios request configuration.
* @returns The config with additional `multipart/form-data` headers if appropriate.
*/
export declare function formData(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
/**
* An {@link axios} request interceptor to log requests.
*
* @param config The axios request configuration.
* @returns The original config.
*/
export declare function requestLogger(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
/**
* An {@link axios} response interceptor to log responses.
*
* @param response The axios response.
* @returns The original response.
*/
export declare function responseLogger(response: AxiosResponse): AxiosResponse;
/**
* Configure the default Axios instance.
*
* This applies the interceptors in this modules and sets the appropriate user agent string.
*
* @param name A PascalCase representation of the client.
* @param version The version of the client to represent.
*/
export declare function configureAxios(name: string, version: string): void;
export {};