Reputation: 501
I want to overrride the following route which was generated by nestjsx:
GET /offer-event-matchings/{id}
To get the id from the CrudRequest I wrote the following code.
@Override()
getOne(@ParsedRequest() req: CrudRequest): Promise<GetUserDto> {
const id = req.parsed.search.$and[1]['id']['$eq'];
return this.service.getOfferEventMatching(id);
}
It works but I think and hope there is a better and more beautiful way to get the id from the CrudRequest object?
Upvotes: 3
Views: 1160
Reputation: 1903
The bottom of the section Routes Override in the docs mentions you can use the typical decorators as well, so the easiest would be to use Param
:
getOne(
@ParsedRequest() req: CrudRequest,
@Param('id') id: string
): Promise<GetUserDto> {
// code here
}
Upvotes: 3