SonarQ test on PR #1
48
src/items/items.controller.ts
Normal file
48
src/items/items.controller.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user