Skip to content

Instantly share code, notes, and snippets.

@airscholar
Created July 18, 2022 18:53
Show Gist options
  • Save airscholar/d0560877f524ea82565a18e79e2403ca to your computer and use it in GitHub Desktop.
Save airscholar/d0560877f524ea82565a18e79e2403ca to your computer and use it in GitHub Desktop.
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
} 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()
async create(@Body() createTodoDto: CreateTodoDto) {
return await this.todosService.create(createTodoDto);
}
@Get()
async findAll() {
return await this.todosService.findAll();
}
@Get(':id')
async findOne(@Param('id') id: string) {
return await this.todosService.findOne(id);
}
@Patch(':id')
async update(@Param('id') id: string, @Body() updateTodoDto: UpdateTodoDto) {
return await this.todosService.update(id, updateTodoDto);
}
@Delete(':id')
async remove(@Param('id') id: string) {
return await this.todosService.remove(id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment