在一个自定义装饰器Param中,我有一个console.log,它只运行一次。如何让它像在nestjs中一样在每次请求时返回一个新的id值?
@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);
1条答案
按热度按时间wvt8vs2t1#
decorator.ts
controller.ts
server.ts