I'm usin NestJs, and in many of my controllers I'm using :
@Post(":id")
public create(
@Param('id', new ParseIntPipe()) id: number,
@Body(new ValidationPipe({transform: true})) myData: MyClass) {
// ...
}
I would like to clean my code by creating a custom decorator, for instance:
@Bind() => @Body(new ValidationPipe({transform: true}))
or
@Id() => @Param('id', new ParseIntPipe())
then the code would be much more cleaner than before:
@Post(":id")
public create(@Id() id: number, @Bind() myData: MyClass) {
// ...
}
What is the correct way to inherit those decorators like this?
Thanks