/// import * as rd from "route-declaration"; import * as expressCore from "express-serve-static-core"; import { Locals } from "../locals"; import { __RequestValueHandler, __ErrorValueHandler } from "../value-handler"; import { __RequestVoidHandler, __ErrorVoidHandler } from "../void-handler"; import { __AsyncRequestVoidHandler, __AsyncErrorVoidHandler } from "../async-void-handler"; import { AsyncRequestValueHandler, AsyncErrorValueHandler } from "../async-value-handler"; import * as http from "http"; import * as AppUtil from "./util"; import { IRouter } from "../router"; import { IRoute } from "../route"; import * as RouteDeclarationUtil from "../route-declaration-util"; export interface AppData { __hasParentApp: boolean; locals: Locals; } export declare type IAppBase = (Omit & { __hasParentApp: DataT["__hasParentApp"]; } & { /** * Express instance itself is a request handler/ */ (req: AppUtil.AssertExpressAppCompatible, res: expressCore.Response | http.ServerResponse): any; } & { (req: AppUtil.AssertExpressAppCompatible, res: expressCore.Response, next: expressCore.NextFunction): any; } & { IncomingMessage?: AppUtil.AssertExpressAppCompatible; }); /** Completely backwards compatible with `express`, unless already used by a parent app. */ export interface IApp extends IAppBase { voidHandler(handler: __RequestVoidHandler, ReturnT>): (IApp); /** This method was added as a workaround for, https://github.com/microsoft/TypeScript/issues/31867 */ errorVoidHandler(handler: __ErrorVoidHandler, ReturnT>): (IApp<{ __hasParentApp: DataT["__hasParentApp"]; locals: Partial; }>); /** If passing a function literal, you'll probably need to specify `NextLocalsT` as TS will not be able to infer it properly. */ valueHandler(handler: __RequestValueHandler, NextLocalsT, ReturnT>): (IApp<{ __hasParentApp: DataT["__hasParentApp"]; locals: (DataT["locals"] & NextLocalsT); }>); /** If passing a function literal, you'll probably need to specify `NextLocalsT` as TS will not be able to infer it properly. */ /** This method was added as a workaround for, https://github.com/microsoft/TypeScript/issues/31867 */ errorValueHandler(handler: __ErrorValueHandler, NextLocalsT, ReturnT>): (IApp<{ __hasParentApp: DataT["__hasParentApp"]; locals: Partial; }>); asyncVoidHandler = Promise>(handler: __AsyncRequestVoidHandler, ReturnT>): (IApp); /** This method was added as a workaround for, https://github.com/microsoft/TypeScript/issues/31867 */ asyncErrorVoidHandler = Promise>(handler: __AsyncErrorVoidHandler, ReturnT>): (IApp<{ __hasParentApp: DataT["__hasParentApp"]; locals: Partial; }>); asyncValueHandler(handler: AsyncRequestValueHandler, NextLocalsT>): (IApp<{ __hasParentApp: DataT["__hasParentApp"]; locals: (DataT["locals"] & NextLocalsT); }>); /** This method was added as a workaround for, https://github.com/microsoft/TypeScript/issues/31867 */ asyncErrorValueHandler(handler: AsyncErrorValueHandler, NextLocalsT>): (IApp<{ __hasParentApp: DataT["__hasParentApp"]; locals: Partial; }>); /** Creates a new sub app. The new sub app is automatically "used" by the parent app. Internally, it does something like, ```ts const subApp = app(); for (let h of this.handlers) { subApp.voidHandler(h); } this.use(subApp); ``` */ createSubApp(path?: string): (IApp<{ __hasParentApp: true; locals: DataT["locals"]; }>); /** Creates a new router. The new router is automatically "used" by the parent app. Internally, it does something like, ```ts const r = router(); for (let h of this.handlers) { r.voidHandler(h); } this.use(r); ``` */ createRouter(path?: string): (IRouter<{ __hasParentApp: true; locals: DataT["locals"]; }>); createRoute(routeDeclaration: RouteDeclarationT): IRoute>; } export declare type IMainApp> = (IApp); export interface ParentApp { /** Creates a new sub app. The new sub app is automatically "used" by the parent app. Internally, it does something like, ```ts const subApp = app(); for (let h of this.handlers) { subApp.voidHandler(h); } this.use(subApp); ``` */ createSubApp(path?: string): (IApp<{ __hasParentApp: true; locals: LocalsT; }>); /** Creates a new router. The new router is automatically "used" by the parent app. Internally, it does something like, ```ts const r = router(); for (let h of this.handlers) { r.voidHandler(h); } this.use(r); ``` */ createRouter(path?: string): (IRouter<{ __hasParentApp: true; locals: LocalsT; }>); createRoute(routeDeclaration: RouteDeclarationT): IRoute>; } //# sourceMappingURL=app.d.ts.map