Routes and responses
Send one clear response
Choose status, headers, content type, and body deliberately and return after completing the response.
9 minute lesson
Creating a note returns the appropriate success status and representation, while an empty delete does not invent a JSON body. That contrast gives us something useful to test instead of a rule to memorize.
A handler must either finish the response, delegate, or throw; continuing after a send causes double-response bugs. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.
The happy path can hide a bad design: you can send a response and continue into code that can send or mutate state again and still get one successful demo. Push past the demo. make every branch visibly return, delegate, or fail and test the response status and content type, then test the condition most likely to prove the choice wrong.
The module is moving toward one outcome: Design routes that match intentionally, parse input from the correct location, and return one complete response. Save the before-and-after evidence now; it will make the final project review much more honest.
Instrument one handler with success, validation, missing-record, and failure branches and prove each terminates once. Save the evidence, then explain which requirement would force you to choose a different design.
Lesson completed