Sikau

NestJS · Day 5 · about 40 min

Project: Staff module

A complete feature module from scratch.

Module, service, controller

Build a staff feature the Nest way: a service with the logic, a controller with the routes, and a module that ties them together — then plug it into the app.

Check it like a client

When the feature compiles, test it the way a client would. Request GET /staff and expect the full list; request GET /staff/1 and expect one person; request GET /staff/99 and expect a 404 with a helpful message. Testing the unhappy path is just as important as the happy one, because that's where real users get stuck.

If a route answers 404 for everything, check the module wiring first. If it answers 500, read the server log: an unconverted id or a missing provider is usually the cause.

Tools like curl, HTTPie or the REST Client extension let you save these requests and re-run them after every change.

The rest of this lesson

  • Plan the feature before typingexplain
  • Where errors belongexplain
  • Who owns it?match
  • Build orderorder
  • The staff featurechallenge
  • Badge quizquiz
  • Unit 1 complete!recap

Continue this lesson free — run real code in your browser

Continue with Google

See all 15 lessons of NestJS