Files
main.tsmain
What you'll learn
- Declare routes whose paths compose from the controller prefix and the method path
- Read route parameters, the query string and the JSON body with parameter decorators, and treat them as the strings they are
- Write an async handler that awaits a service, and override a POST's default 201 with @HttpCode()
Press Run tests to start the app. Its log appears here.Graded endpoints
The route from lesson 1 still answers
The :name segment reaches the handler through @Param('name'), and the awaited greeting comes back as JSON
?shout=true reaches the handler through @Query('shout') and upper-cases the greeting
The value is the string 'false', which is not false: only the exact string 'true' should shout
Route parameters arrive URL-decoded: %20 is a space by the time the handler sees it
The parsed body comes back under received, with 200 instead of a POST's default 201