diff --git a/Server/src/Plugs/API/API.ts b/Server/src/Plugs/API/API.ts index 57400bf..29c91b2 100644 --- a/Server/src/Plugs/API/API.ts +++ b/Server/src/Plugs/API/API.ts @@ -1,11 +1,22 @@ +import { Request, Response, NextFunction } from "express"; import Logger from "../Logger"; +interface MiddlewareFunction { + (req: Request, res: Response, next: NextFunction): void; +} + abstract class API { protected logger: Logger; public middlewareFunc: Function[] = []; - constructor(public method: string, public uri: string, ...func: any) { - this.logger = new Logger('API][' + method + '][' + uri); + + /** + * @param method API方法 + * @param path API路由Path + * @param func API中间件函数 + */ + constructor(public method: string, public path: string, ...func: MiddlewareFunction[]) { + this.logger = new Logger('API][' + method + '][' + path); this.middlewareFunc.push(...func); }