I am trying to combine multiple Parameter Decorator for my application. In my application there are several custom decorators. My Sample Controller.
@Controller('api')
export class MyController {
@Get('mainresponse')
public getResponse(
@Query() query: Partial<IBean>,
@Headers('user-agent') userAgent: string,
@MyFirstDocrator() firstDecorator: string,
@MySecondDocrator() secondDecorator: string,
@Headers('Referer') referer: string,
@Cookies('session') sessionId?: string,
): Observable<IResponse> {
......
}
}
I am trying to combine these decorators into 1 and return an object with all the decorators value. Something like this
@Get('mainresponse')
public getResponse(
@MyCombinedDecorator() decorator: any
): Observable<IResponse> {
......
}
But when I am using applyDecorators it is giving me the return value of the last passed decorator.
export const MyCombinedDecorator = () => applyDecorators(Headers('user-agent') as PropertyDecorator, MyFirstDocrator() as PropertyDecorator, Query() as PropertyDecorator);