@lakutata/core
Version:
Lakutata Framework Core
46 lines (45 loc) • 1.78 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { Plugin } from '../base/Plugin';
import { URL } from 'url';
import { NeedleOptions as HttpRequestOptions } from 'needle';
import { HttpRequestException } from '../exceptions/HttpRequestException';
declare module '../Core' {
interface Application {
HttpRequest: HttpRequest;
}
}
export declare class HttpRequest extends Plugin {
multipartUpload<T = any>(setting: {
method?: 'post' | 'put';
url: string | URL;
filename?: string;
file: string;
contentType?: string;
field?: string;
options?: HttpRequestOptions;
}): Promise<T>;
download(setting: {
method?: 'get' | 'post';
url: string | URL;
filename: string;
params?: {
[key: string]: any;
} | string | null;
options?: HttpRequestOptions;
}, progressCallback?: (exception: HttpRequestException | null, isDone: boolean, progress: number) => void): Promise<void>;
get<T = any>(url: string | URL, options?: HttpRequestOptions): Promise<T>;
post<T = any>(url: string | URL, body: {
[key: string]: any;
} | string | Buffer | null, options?: HttpRequestOptions): Promise<T>;
put<T = any>(url: string | URL, body: {
[key: string]: any;
} | string | Buffer | null, options?: HttpRequestOptions): Promise<T>;
patch<T = any>(url: string | URL, body: {
[key: string]: any;
} | string | Buffer | null, options?: HttpRequestOptions): Promise<T>;
delete<T = any>(url: string | URL, body: {
[key: string]: any;
} | string | Buffer | null, options?: HttpRequestOptions): Promise<T>;
head(url: string | URL, options?: HttpRequestOptions): Promise<boolean>;
}