import { IncomingMessage, ServerResponse } from 'http'; import { ServerRoute as Route } from './route'; import { NextFunction } from './utils'; import { ModernServerContext } from './context'; type Middleware = ( req: IncomingMessage, res: ServerResponse, next: NextFunction, ) => Promise; export type TemplateAPI = { get: () => Promise; set: (html: string) => void; prependBody: (frag: string) => TemplateAPI; prependHead: (frag: string) => TemplateAPI; appendBody: (frag: string) => TemplateAPI; appendHead: (frag: string) => TemplateAPI; replace: (tag: string, frag: string) => TemplateAPI; }; export type RouteAPI = { cur: () => Route; get: (entryName: string) => Route | undefined; use: (entryName: string) => boolean; }; type HookHandler = (ctx: Context, next: NextFunction) => Promise; type Hook = (fn: HookHandler) => void; export type ModernServerHook = { beforeMatch: Hook; afterMatch: Hook; beforeRender: Hook; afterRender: Hook; };