You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1020 B
49 lines
1020 B
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Patch,
|
|
Param,
|
|
Delete,
|
|
HttpCode,
|
|
} from '@nestjs/common';
|
|
import { TodosService } from './todos.service';
|
|
import { CreateTodoDto } from './dto/create-todo.dto';
|
|
import { UpdateTodoDto } from './dto/update-todo.dto';
|
|
|
|
@Controller('todos')
|
|
export class TodosController {
|
|
constructor(private readonly todosService: TodosService) {}
|
|
|
|
@Post()
|
|
create(@Body() createTodoDto: CreateTodoDto) {
|
|
return this.todosService.create(createTodoDto);
|
|
}
|
|
|
|
@Get()
|
|
findAll() {
|
|
return this.todosService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(@Param('id') id: string) {
|
|
return this.todosService.findOne(id);
|
|
}
|
|
|
|
@Post('delete-all')
|
|
@HttpCode(200)
|
|
deleteAll() {
|
|
return this.todosService.deleteAll();
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(@Param('id') id: string, @Body() updateTodoDto: UpdateTodoDto) {
|
|
return this.todosService.update(id, updateTodoDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id') id: string) {
|
|
return this.todosService.remove(id);
|
|
}
|
|
}
|