From d3476ed41906dabd7b030fd070fbfd5c06461282 Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Fri, 6 Sep 2024 11:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9APILoader=E4=BB=A5=E4=BF=9D?= =?UTF-8?q?=E6=8C=81API=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/src/Plugs/API/APILoader.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Server/src/Plugs/API/APILoader.ts b/Server/src/Plugs/API/APILoader.ts index dbe4c9b..b64ab56 100644 --- a/Server/src/Plugs/API/APILoader.ts +++ b/Server/src/Plugs/API/APILoader.ts @@ -20,19 +20,19 @@ class APILoader { add(api: { new(): API }) { const instance = new api(); for (let func of instance.middlewareFunc) { - this.app[instance.method.toLowerCase() as keyof express.Application](instance.uri, (req: Request, res: Response, next: NextFunction) => { + this.app[instance.method.toLowerCase() as keyof express.Application](instance.path, (req: Request, res: Response, next: NextFunction) => { func(req, res, next); }); - this.logger.info(`[${instance.method}][${instance.uri}] 已启用中间件[${func.name}]`); + this.logger.info(`[${instance.method}][${instance.path}] 已启用中间件[${func.name}]`); } - this.app[instance.method.toLowerCase() as keyof express.Application](instance.uri, (req: Request, res: Response) => { + this.app[instance.method.toLowerCase() as keyof express.Application](instance.path, (req: Request, res: Response) => { let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.ip; - this.logger.info(`[${instance.method}][${instance.uri}] 被请求[${(ip as string).replace('::ffff:', '')}]`); + this.logger.info(`[${instance.method}][${instance.path}] 被请求[${(ip as string).replace('::ffff:', '')}]`); const data = Object.assign({}, req.query, req.body); instance.onRequset(data, res); }); - this.logger.info(`[${instance.method}][${instance.uri}] 加载成功`); + this.logger.info(`[${instance.method}][${instance.path}] 加载成功`); } start(port?: number) {