jsfast
Version:
Fastjs(jsfast) is a useful, lightweight JavaScript library for any types of project.
35 lines (34 loc) • 1.13 kB
TypeScript
import type { FailedParams, RequestHookParam } from "./def";
import type { RequestReturn, RequestReturnData } from "./def";
import type { FastjsRequest } from "./fetch-types";
export interface GlobalConfig {
timeout: number;
hooks: RequestHookParam;
handler: {
handleResponse: (response: Response, request: FastjsRequest) => Promise<any>;
responseCode: (code: number, request: FastjsRequest) => boolean;
};
check: {
ignoreFormatWarning: boolean;
stringBodyWarning: boolean;
unrecommendedMethodWarning: boolean;
};
}
export declare const globalConfig: GlobalConfig;
export declare function createConfig(config?: Partial<RequestConfig>): RequestConfig;
export interface RequestConfig {
timeout: number;
headers: {
[key: string]: string;
};
wait: number;
failed: (error: FailedParams<Error | number>) => void;
callback: (data: RequestReturnData, response: RequestReturn) => void;
query: {
[key: string]: any;
} | string | null;
body: {
[key: string]: any;
} | string | null;
hooks: RequestHookParam;
}