UNPKG

@getanthill/datastore

Version:

Event-Sourced Datastore

50 lines (49 loc) 1.57 kB
/// <reference types="node" /> import { EventEmitter } from 'events'; import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; export interface CoreConfig { token: string; baseUrl?: string; timeout?: number; debug?: boolean; telemetry?: any; retriableMethods: Array<string>; retriableErrors: Array<string>; maxRetry: number; } export default class Core extends EventEmitter { static ERRORS: {}; static DEFAULT_RETRIABLE_METHODS: string[]; static DEFAULT_RETRIABLE_ERRORS: string[]; static DEFAULT_MAX_RETRY: number; static DEFAULT_HEADERS: Readonly<{ 'Content-Type': "application/json"; Accept: "application/json"; }>; private _config; private _axios; private _telemetry; private _recordHttpRequestDuration; constructor(config?: Partial<CoreConfig>); static paramsSerializer(params: { [key: string]: any; }): string; private cloneAxiosError; getToken(): string; setTimeout(timeout: number): void; getPath(...fragments: (string | number | Date)[]): string; inspect(obj: { [key: string]: any; }): { [key: string]: any; }; request(config: AxiosRequestConfig): Promise<AxiosResponse>; /** * @warn this interceptor is here to handle race conditions * happening in Node.js 20 with `keepAlive` enabled with parallel * requests. * * @see https://github.com/node-fetch/node-fetch/issues/1735 */ responseInterceptor(error: AxiosError): Promise<AxiosResponse<any, any>>; }