Complete the code to import the necessary decorator for creating a controller in NestJS.
import { [1] } from '@nestjs/common'; @Controller('items') export class ItemsController {}
The @Controller decorator is used to define a controller in NestJS.
Complete the code to define a GET route handler method named 'findAll' in the controller.
@Controller('items') export class ItemsController { @[1]() findAll() { return 'This action returns all items'; } }
The @Get() decorator defines a handler for HTTP GET requests.
Fix the error in the method to accept an 'id' parameter from the URL path.
@Get(':id') findOne(@[1]('id') id: string) { return `This action returns item #${id}`; }
The @Param('id') decorator extracts the 'id' parameter from the URL path.
Fill both blanks to create a POST method that accepts a data object from the request body and returns it.
@Post() create(@[1]() createItemDto: any) { return [2]; }
The @Body() decorator extracts the request body, and returning createItemDto sends back the received data.
Fill all three blanks to create a DELETE method that accepts an 'id' parameter and returns a confirmation string.
@Delete(':id') remove(@[1]('id') id: string) { return `Item with id ${id} has been [2]`; } // Use this method in the controller to handle deletion requests.
The @Param('id') decorator extracts the 'id' from the URL, and the string uses 'removed' to confirm deletion.