import { Body, Controller, Delete, Get, HttpCode, Param, ParseIntPipe, Post, Put, } from '@nestjs/common'; import { ItemsService } from './items.service'; class CreateItemDto { name: string; description?: string; } @Controller('api/items') export class ItemsController { constructor(private readonly items: ItemsService) {} @Get() findAll() { return this.items.findAll(); } @Post() @HttpCode(201) create(@Body() dto: CreateItemDto) { return this.items.create(dto.name, dto.description); } @Get(':id') findOne(@Param('id', ParseIntPipe) id: number) { return this.items.findOne(id); } @Put(':id') update(@Param('id', ParseIntPipe) id: number, @Body() dto: CreateItemDto) { return this.items.update(id, dto.name, dto.description); } @Delete(':id') remove(@Param('id', ParseIntPipe) id: number) { return this.items.remove(id); } }