Description
Currently expressjs supports requests with multiple parameters as shown:
In the endpoint below we are passing an id and id2 as parameters
http://localhost:3000/users/1/2
In the express.Request you can see the object that lists all these parameters as such:
{ id: '1', id2: '2' }
@Get("/:id/:id2")
findOne(req: express.Request) {
console.log(req.params);
return this.userUseCase.findOne(+req.params.id);
}
We need to modify the @param decorator to support multiple parameters. Also, we need to investigate the possibility to validate the types passed in the parameter.
The initial idea would be to use the types inferred by the parameter name to either automatically convert to the type suggested.
@Patch("/:id")
update(@param("id") id: number, @body() userUpdated: IUsersRequestDto) {
return this.userUseCase.update(id, userUpdated);
}
As the code above shows, the id would take the property id name and convert by its type, in this case number
Requirement
Description
Currently
expressjssupports requests with multiple parameters as shown:In the endpoint below we are passing an id and id2 as parameters
http://localhost:3000/users/1/2In the
express.Requestyou can see the object that lists all these parameters as such:{ id: '1', id2: '2' }We need to modify the
@paramdecorator to support multiple parameters. Also, we need to investigate the possibility to validate the types passed in the parameter.The initial idea would be to use the types inferred by the parameter name to either automatically convert to the type suggested.
As the code above shows, the id would take the property
idname and convert by its type, in this casenumberRequirement