Coding task · NestJS course · Module 1: NestJS Basics

Query and Route Parameters

Create a controller that uses URL and query string parameters.

Task

Write a LegionController with the @Controller('legion') decorator and two GET endpoints: search with @Get('search'), which reads @Query('province') province and returns { province }, and findOne with @Get(':id'), which reads @Param('id') id and returns { id }. Declare search before :id, because the route with a parameter would capture the /legion/search address.