From 030cdf0be2b0005a4447059a344e042450d9d704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=99=8C?= <412799755@qq.com> Date: Thu, 26 Oct 2023 15:40:58 +0800 Subject: [PATCH] feat: change decorator name --- core/controller-decorator/src/decorator/http/HTTPParam.ts | 2 +- .../apps/controller-app/app/controller/AppController.ts | 4 ++-- plugin/controller/test/http/params.test.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/controller-decorator/src/decorator/http/HTTPParam.ts b/core/controller-decorator/src/decorator/http/HTTPParam.ts index 3cd83e58..2818704a 100644 --- a/core/controller-decorator/src/decorator/http/HTTPParam.ts +++ b/core/controller-decorator/src/decorator/http/HTTPParam.ts @@ -69,7 +69,7 @@ export function HTTPParam(param?: HTTPParamParams) { }; } -export function InjectHTTPRequest() { +export function Request() { return function(target: any, propertyKey: PropertyKey, parameterIndex: number) { assert(typeof propertyKey === 'string', `[controller/${target.name}] expect method name be typeof string, but now is ${String(propertyKey)}`); diff --git a/plugin/controller/test/fixtures/apps/controller-app/app/controller/AppController.ts b/plugin/controller/test/fixtures/apps/controller-app/app/controller/AppController.ts index cad9e931..8ac99389 100644 --- a/plugin/controller/test/fixtures/apps/controller-app/app/controller/AppController.ts +++ b/plugin/controller/test/fixtures/apps/controller-app/app/controller/AppController.ts @@ -7,7 +7,7 @@ import { HTTPMethodEnum, HTTPParam, HTTPQuery, - InjectHTTPRequest, + Request, Middleware, Inject, HTTPRequest, @@ -54,7 +54,7 @@ export class AppController { method: HTTPMethodEnum.POST, path: '', }) - async save(@Context() ctx: EggContext, @HTTPBody() app: App, @InjectHTTPRequest() request: HTTPRequest) { + async save(@Context() ctx: EggContext, @HTTPBody() app: App, @Request() request: HTTPRequest) { const traceId = await ctx.tracer.traceId; async function streamToString(stream) { const decoder = new TextDecoder(); diff --git a/plugin/controller/test/http/params.test.ts b/plugin/controller/test/http/params.test.ts index b2ef16cd..d3d4d367 100644 --- a/plugin/controller/test/http/params.test.ts +++ b/plugin/controller/test/http/params.test.ts @@ -99,7 +99,7 @@ describe('test/params.test.ts', () => { }); }); - it('InjectHTTPRequest should work', async () => { + it('Request should work', async () => { app.mockCsrf(); const param = { name: 'foo',