/// import { RequestError } from "@gongt/ts-stl-library/request/request-error"; import { EventEmitter } from "events"; import * as express from "express"; import { Application, ErrorRequestHandler, NextFunction, PathParams, Request, RequestHandler, Response } from "express-serve-static-core"; import { CrossDomainMiddleware } from "../communication/crossdomain/middleware"; import { ExpressHandler } from "../express/base/handler"; import { ServeStaticEx } from "../express/inject/serve-static"; export declare function createExpressApp(): ExpressAppBuilder; export declare function createRouterOn(router: ExpressBuilder, path: string): ExpressRouterBuilder; export declare type StaticLocalPath = { localPath: string; }; export declare type RequestHandlerWithPath = { path: string; handler: RequestHandler; }; export declare abstract class ExpressBuilder extends EventEmitter { protected path: string; protected middlewares: { prepend: RequestHandlerWithPath[]; publicDirs: (RequestHandlerWithPath & StaticLocalPath)[]; express_handlers: ExpressHandler[]; prependAfterPublic: (PathParams | ErrorRequestHandler | RequestHandler)[][]; prependBeforePublic: (PathParams | ErrorRequestHandler | RequestHandler)[][]; }; protected router: express.Router & any; protected selfIsRoot: boolean; protected rootBuilderObject: ExpressAppBuilder; protected finished: boolean; protected childrens: ExpressBuilder[]; protected routerInitCallback: (router: Application) => void; protected errorHandler: ErrorRequestHandler; protected commonInit(): void; constructor(path: string, parent: ExpressBuilder); mountPublic(path: string, fsPath: string, serveStaticOptions?: ServeStaticEx): void; prependMiddleware(...handlers: (ErrorRequestHandler | RequestHandler)[]): any; prependMiddleware(path: PathParams, ...handlers: (ErrorRequestHandler | RequestHandler)[]): any; registerMiddleware(...handlers: (ErrorRequestHandler | RequestHandler)[]): any; registerMiddleware(path: PathParams, ...handlers: (ErrorRequestHandler | RequestHandler)[]): any; registerHandler(handler: ExpressHandler): void; registerHandlersFromDir(dir: string, decorator?: (e: ExpressHandler) => void): void; protected finish(): void; protected prePublic(): void; protected preMount(): void; protected postMount(): void; } export declare type CustomLogger = (req: Request, res: Response) => string; export declare type ViewFunc = (path: string, options: any, callback: (err: Error, html: string) => void) => void; export declare class ExpressAppBuilder extends ExpressBuilder { protected _rootPath: string; protected logger: RequestHandler; protected errorHandler: ErrorRequestHandler; private viewEngineSettings; constructor(path: string); protected preMount(): void; protected postMount(): void; setDefaultLogging(format: string | CustomLogger): void; setServerRootPath(path: any): void; setView(viewFolder: string, defaultEngine: string): void; addView(name: string, func?: ViewFunc): void; setCors(path: string, obj: CrossDomainMiddleware): void; setFaviconPath(path: string, ttlSecond: number): void; readonly serverRootPath: string; private mountAllPending(); generateApplication(router?: express.Application & any): express.Application; } export declare class ExpressRouterBuilder extends ExpressBuilder { constructor(path: string, parent: ExpressBuilder); internalProtect(path?: string): { withKey(newKey: string): void; }; routerOptions(cb: (router: Application) => void): void; protected postMount(): void; } export declare function defaultErrorHandler(error: Error | RequestError, req: Request, res: Response, next: NextFunction): Response;