/// import type { IncomingMessage, ServerResponse } from "http"; import { SchemaObject } from './OpenApi'; /** * @description Supported http content_type */ export declare type HttpContentType = "text/plain" | "application/json"; /** * @description Supported http method */ export declare type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH"; /** * @description Enum of supported http content_type */ export declare const HttpContentTypeEnum: Record; /** * @description Enum of supported http method */ export declare const HttpMethodEnum: Record; /** * @description Array of supported http method */ export declare const HttpMethodKey: string[]; export declare type HttpReqParams = Record; export declare type HttpReqSearchParams = Record; export declare type HttpReqBody = any | any[]; /** * @description Partial http request before it send to route */ export interface HttpReqPartial extends IncomingMessage { p_url: URL; method: HttpMethod; p_body: HttpReqBody; p_params: HttpReqParams; p_sp: HttpReqSearchParams; } /** * @description HttpErr constructor argument */ export declare type HttpErrCtorArg = { status_code: number; } & Record; /** * @description Http Error class Helper */ export declare class HttpErr { body: string; status_code: number; constructor(arg: HttpErrCtorArg); } /** * @description Default Http response */ export declare class HttpRes { body: string; is_stream?: boolean; status_code: number; content_type: string; constructor(data: HttpRes); } export declare type CtrlBinder = () => RouteConf; export declare class Ctrl { path: string; [props: string]: CtrlBinder | any; constructor(path?: string); } export declare type RouteDataType = { schema?: SchemaObject; content_type?: HttpContentType; }; export declare type RouteReqSp = Record; export declare type RouteReq = { title?: string; body: RouteDataType; search_params: RouteReqSp; }; export declare type RouteVar = Record; export declare type RouteRes = { title?: string; status_code: number; content: RouteDataType; is_stream?: boolean; }; export declare type RouteConfGetter = () => [RouteReq, RouteRes]; export declare class RouteConf { req: RouteReq; res: RouteRes; pathname: string; fn: RouteExec; constructor(getter: RouteConfGetter); bind_route: RouteBinder; } export declare type RouteExec = (req: HttpReqPartial, res: ServerResponse) => Promise; export declare type RouteBinder = (fn: RouteExec) => void;