portals
Version:
Client-side HTTP requests with middleware support.
38 lines (37 loc) • 1.16 kB
TypeScript
export declare type Request<Body = any> = {
url: string;
method?: HttpMethodLiteral | Method;
headers?: HttpHeaderLiteral;
body?: Body;
withCredentials?: boolean;
};
export declare type Response<Body = any> = {
statusCode: number;
headers: HttpHeaderLiteral;
contentType: null | string;
xhr: XMLHttpRequest;
body: Body;
};
export interface NextFunction<Response> {
(): Promise<Response>;
}
export declare type HttpHeaderLiteral = {
[key: string]: string | string[];
};
export declare type HttpMethodLiteral = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "UPDATE";
export declare enum Method {
GET = "GET",
POST = "POST",
PUT = "PUT",
PATCH = "PATCH",
DELETE = "DELETE",
HEAD = "HEAD",
UPDATE = "UPDATE"
}
export declare type Middleware<Req extends Request = Request, Res extends Response = Response> = (request: Req, next: NextFunction<Res>) => Promise<Res>;
export * from "./portal";
export * from "./supportsJson";
export * from "./withPrefix";
export * from "./withHeader";
export * from "./withAuth";
export * from "./withXSRFToken";