@busymango/fetch-driver
Version:
64 lines (63 loc) • 1.87 kB
TypeScript
import { DataStringifyFunc, DriverRequest } from './types';
type InitParams = {
stringify: DataStringifyFunc;
};
export declare class DriveContext<T = unknown> {
api: string;
url: URL | null;
path: string;
req: DriverRequest;
data?: object;
res: {
type?: string;
charset?: string;
raw?: Response;
headers?: Headers;
status?: number;
body?: T;
};
static toURL: (api: string) => URL | null;
static randomId: () => string;
constructor(api: string, params?: RequestInit & {
id?: string;
data?: object;
});
private initApi;
private initBody;
private initMethod;
init: ({ stringify }?: Partial<InitParams>) => this;
initAbort: (timeout?: number) => void;
decodeHeader: (response: Response) => void;
clone: () => {
api: string;
url: URL | null;
path: string;
req: {
id: string;
body?: (BodyInit | null) | undefined;
cache?: RequestCache | undefined;
credentials?: RequestCredentials | undefined;
integrity?: string | undefined;
keepalive?: boolean | undefined;
method?: string | undefined;
mode?: RequestMode | undefined;
priority?: RequestPriority | undefined;
redirect?: RequestRedirect | undefined;
referrer?: string | undefined;
referrerPolicy?: ReferrerPolicy | undefined;
signal?: (AbortSignal | null) | undefined;
window?: null | undefined;
headers: Headers;
};
res: {
type?: string;
charset?: string;
raw?: Response;
headers?: Headers;
status?: number;
body?: T;
};
data: object | undefined;
};
}
export {};