Nest.js: Custom decorator that will return parameter from request

442 Views Asked by At

In a custom decorator Param I have a console.log that is run once. How to make it to return me a fresh value of id on each request like in nestjs?

@Get('/:id')
async findUser (
    @Param() id: string | undefined // is not called each time when acces method findUser
  ): Promise<User> {
}



export const Param = () => (target: any, key: string, index: number)  => {
    var indices = Reflect.getMetadata('request', target, key);
    console.log('test', indices)
}



Reflect.defineMetadata('request', event, currentController.prototype, route.methodName);
0

There are 0 best solutions below