UNPKG

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