Created
July 18, 2022 18:53
-
-
Save airscholar/d0560877f524ea82565a18e79e2403ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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