diff --git a/src/task/task.controller.ts b/src/task/task.controller.ts index 6f272a0ce4c9d51e49ec3fbba78d666e283b0910..db6be9176c3d02b13cfc82799fcd7be81b0fe369 100644 --- a/src/task/task.controller.ts +++ b/src/task/task.controller.ts @@ -10,32 +10,27 @@ import { import { TaskService } from './task.service'; import { Roles } from '../shared/roles.decorator'; import { ValidationPipe } from '../shared/validation.pipe'; -import { TaskDTO } from './task.dto'; +import { CreateTaskDTO, EditTaskDTO } from './task.dto'; @Controller('task') export class TaskController { constructor(private taskService: TaskService) {} - /* @Post('new') - @UseGuards(new AuthGuard()) - @UsePipes(new ValidationPipe()) - async newGame(@User('id') person, @Body() body: GameDTO) { - return this.gameservice.createNewGame(person, body); - } - - @Put(':id') - @Roles('admin') - @UsePipes(new ValidationPipe()) - async editGame(@Param('id') id: string, @Body() body: GameDTO) { - return this.gameservice.editGame(id, body); - } */ - // creates a new task if the user has admin role in the game // :id is the id of the game @Post('new-task/:id') - //@Roles('admin') + @Roles('admin') @UsePipes(new ValidationPipe()) - async newTask(@Param('id') id: string, @Body() task: TaskDTO) { + async newTask(@Param('id') id: string, @Body() task: CreateTaskDTO) { return this.taskService.newTask(task); } + + // edits a created task if the user has admin role in the game + // :id is the id of the game + @Post('edit-task/:id') + @Roles('admin') + @UsePipes(new ValidationPipe()) + async editTask(@Param('id') id: string, @Body() data: EditTaskDTO) { + return this.taskService.editTask(data); + } }