Controllers map HTTP to methods

A controller is a routing table made of methods

In Express you called app.get("/walkers/:id", handler). In Nest the route lives on the method as a decorator, and the class groups every route under one path prefix:

  • @Controller("walkers") β€” every method in this class hangs off /walkers.
  • @Get() on a method β†’ GET /walkers. @Get(":id") β†’ GET /walkers/:id.
  • @Post() β†’ POST /walkers.
  • @Param("id") pulls :id out of the path into a method argument. @Body() gives you the parsed JSON body.

The method's return value becomes the response body β€” Nest serializes it to JSON and sends 200 (or 201 for a @Post) for you. No res.json(), no res.status() in the common case.