/// import type { Dispatcher, Pool } from 'undici'; import type { URL } from 'url'; export type Result = { statusCode: Dispatcher.ResponseData['statusCode']; headers: Dispatcher.ResponseData['headers']; data: R; }; /** * Open an HTTP connection pool */ export declare class Connection { private _pool; constructor(); /** * Wrapper to handle HTTP error codes. HTTP errors don't trigger any * exceptions because it is optional to handle error status codes. * @param response to handle * @param handler to execute * @returns */ static onHttpError(response: Promise>, handler: (result: Result) => HR): Promise
>; /** * Initiates a new connection pool * @param url * @param options * @returns */ open(url: string | URL, options?: Pool.Options): void; /** * Perform a request * @param method * @param endpoint * @param headers * @param body * @param parseResponse * @returns */ raw(method: 'POST' | 'GET', endpoint: string, headers?: Dispatcher.DispatchOptions['headers'], body?: Dispatcher.DispatchOptions['body'], parseResponse?: boolean): Promise>; /** * Perform a POST request * @param endpoint * @param body * @param headers * @param parseResponse * @returns */ post(endpoint: string, body?: Dispatcher.DispatchOptions['body'], headers?: Dispatcher.DispatchOptions['headers'], parseResponse?: boolean): Promise>; /** * Perform a GET request * @param endpoint * @param body * @param headers * @returns */ get(path: string, headers?: Dispatcher.DispatchOptions['headers']): Promise>; /** * Close the connections */ close(): void; }