Last active
October 4, 2022 11:35
-
-
Save Vivek205/25e1dda1f8cfca64faf2c1cc8f301b05 to your computer and use it in GitHub Desktop.
Task controller to map the service handlers for the http methods
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 { | |
Body, | |
Controller, | |
Delete, | |
Get, | |
Param, | |
Patch, | |
Post, | |
Query, | |
} from '@nestjs/common'; | |
import { CreateTaskDto } from './dto/create-task.dto'; | |
import { FilterTasksDto } from './dto/filter-tasks.dto'; | |
import { UpdateTaskStatusDto } from './dto/update-task-status.dto'; | |
import { TasksService } from './tasks.service'; | |
@Controller('tasks') | |
export class TasksController { | |
constructor(private tasksService: TasksService) {} | |
@Get() | |
getTasks(@Query() filterTasksDto: FilterTasksDto) { | |
return this.tasksService.getTasks(filterTasksDto); | |
} | |
@Get(':id') | |
getTask(@Param('id') id: string) { | |
return this.tasksService.getTaskById(id); | |
} | |
@Post() | |
createTask(@Body() createTaskDto: CreateTaskDto) { | |
return this.tasksService.createTask(createTaskDto); | |
} | |
@Patch(':id/status') | |
updateTaskStatus( | |
@Param('id') id: string, | |
@Body() updateTaskStatusDto: UpdateTaskStatusDto, | |
) { | |
return this.tasksService.updateTaskStatus(id, updateTaskStatusDto); | |
} | |
@Delete(':id') | |
deleteTask(@Param('id') id: string) { | |
return this.tasksService.deleteTask(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment