MΓ³dulo 08 Β· The Walkers API, End to End β LecciΓ³n 2 de 3 Β· ~8 min
GET /walkers/:id β 404 when missing
The :id is a string until you make it a number
GET /walkers/42 carries 42 in the path β but every path param arrives as the string "42". Prisma's id column is an Int, so you must convert, and you want to reject GET /walkers/banana before it ever reaches the database.
Nest ships exactly that as a pipe: ParseIntPipe. Attach it to the param and Nest converts the string to a number, or throws a 400 Bad Request if it isn't one β so your method always receives a real number.
@Get(":id")
findOne(@Param("id", ParseIntPipe) id: number) {
return this.walkers.findOne(id);
}