UNPKG

1.02 kBTypeScriptView Raw
1/// <reference types="node" />
2import { AxiosResponse, AxiosRequestConfig } from "axios";
3import { Readable } from "stream";
4interface httpClientConfig extends Partial<AxiosRequestConfig> {
5 baseURL?: string;
6 defaultHeaders?: any;
7 responseParser?: <T>(res: AxiosResponse) => T;
8}
9export default class HTTPClient {
10 private instance;
11 private config;
12 constructor(config?: httpClientConfig);
13 get<T>(url: string, params?: any): Promise<T>;
14 getStream(url: string, params?: any): Promise<Readable>;
15 post<T>(url: string, body?: any, config?: Partial<AxiosRequestConfig>): Promise<T>;
16 private responseParse;
17 put<T>(url: string, body?: any, config?: Partial<AxiosRequestConfig>): Promise<T>;
18 postForm<T>(url: string, body?: any): Promise<T>;
19 toBuffer(data: Buffer | Readable): Promise<Buffer>;
20 postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>;
21 delete<T>(url: string, params?: any): Promise<T>;
22 private wrapError;
23}
24export {};