/// import * as http from "http"; import { Stream } from "stream"; import Promise, { Thenable } from "yaku"; export interface Context { /** * It will be auto set as the response body. */ body: String | Buffer | Stream | Thenable | Object; /** * An IncomingMessage object is created by http.Server or http. * ClientRequest and passed as the first argument to the 'request' and 'response' event respectively. * It may be used to access response status, headers and data. * https://nodejs.org/api/http.html#http_http_incomingmessage */ req: http.IncomingMessage; /** * This object is created internally by a HTTP server--not by the user. It is passed as the second parameter to the 'request' event. * The response implements the Writable Stream interface. * https://nodejs.org/api/http.html#http_class_http_serverresponse */ res: http.ServerResponse; /** * It returns a promise which settles after all the next middlewares are setttled. */ next: () => Promise; } export interface MiddlewareFn { ($: Context): Thenable | any; } export declare type Middleware = MiddlewareFn | Object; export interface FlowHandler extends MiddlewareFn { (req: http.IncomingMessage, res: http.ServerResponse): Promise; } export default function (middlewares: Middleware[]): FlowHandler;