unmock-types
Version:
Types for [Unmock](https://unmock.io/).
33 lines • 1.2 kB
TypeScript
export declare type OnSerializedRequest = (serializedRequest: ISerializedRequest, sendResponse: (res: ISerializedResponse) => void, emitError: (e: Error) => void) => void;
declare const RESTMethodTypes: readonly ["get", "head", "post", "put", "patch", "delete", "options", "trace"];
export declare type HTTPMethod = typeof RESTMethodTypes[number];
export interface IIncomingHeaders {
[header: string]: string | string[] | undefined;
}
export interface IOutgoingHeaders {
[header: string]: string | string[] | number | undefined;
}
export interface IIncomingQuery {
[key: string]: string | string[] | undefined;
}
export declare type IProtocol = "http" | "https";
export interface ISerializedRequest {
body?: string;
bodyAsJson?: any;
headers: IIncomingHeaders;
host: string;
method: HTTPMethod;
path: string;
pathname: string;
query: IIncomingQuery;
protocol: IProtocol;
}
export interface ISerializedResponse {
bodyAsJson?: any;
body?: string;
headers: IOutgoingHeaders;
statusCode: number;
}
export declare type CreateResponse = (request: ISerializedRequest) => ISerializedResponse;
export {};
//# sourceMappingURL=index.d.ts.map