diff --git a/integrations/sample-app/app/http/controllers/icon.ts b/integrations/sample-app/app/http/controllers/icon.ts index 7bf5ec4..7f140cb 100644 --- a/integrations/sample-app/app/http/controllers/icon.ts +++ b/integrations/sample-app/app/http/controllers/icon.ts @@ -93,8 +93,9 @@ export class IntentController { return { hello: 'world' }; } - @Post('/json') @Validate(LoginDto) + @UseGuards(CustomGuard) + @Post('/json') async postJson( @Req() req: Request, @Dto() dto: LoginDto, @@ -131,9 +132,6 @@ export class IntentController { // userAgent, // ); - // console.log('all headers ===> ', headers); - console.log('uploaded files ==> ', req.dto(), dto); - const readStream = createReadStream( join(findProjectRoot(), 'storage/uploads/sample-image.jpg'), ); diff --git a/packages/core/lib/rest/http-server/decorators.ts b/packages/core/lib/rest/http-server/decorators.ts index f6bd5f2..5fb8177 100644 --- a/packages/core/lib/rest/http-server/decorators.ts +++ b/packages/core/lib/rest/http-server/decorators.ts @@ -84,10 +84,14 @@ export const ANY: RouteDecoratorType = ( export const UseGuards = (...guards: Type[]) => { return function (target: object, key?: string | symbol, descriptor?: any) { if (key) { - Reflect.defineMetadata(GUARD_KEY, guards, target, key); + const existingGuards = Reflect.getMetadata(GUARD_KEY, target, key); + const composeGuards = [...(existingGuards || []), ...guards]; + Reflect.defineMetadata(GUARD_KEY, composeGuards, target, key); return; } - Reflect.defineMetadata(GUARD_KEY, guards, target); + const existingGuards = Reflect.getMetadata(GUARD_KEY, target); + const composeGuards = [...(existingGuards || []), ...guards]; + Reflect.defineMetadata(GUARD_KEY, composeGuards, target); return; }; };