From 26d3982ca6616766f354468b41443d8af83416a5 Mon Sep 17 00:00:00 2001 From: CARLUCCI Romain <romain.carlucci@etu.unistra.fr> Date: Fri, 16 Feb 2024 14:59:00 +0100 Subject: [PATCH] aaaaa --- tp_note_2023_2024/src/requestHandlers/task.ts | 13 +++++++++++++ tp_note_2023_2024/src/routes/routes_tasks.ts | 1 + 2 files changed, 14 insertions(+) diff --git a/tp_note_2023_2024/src/requestHandlers/task.ts b/tp_note_2023_2024/src/requestHandlers/task.ts index c75715a..0dd6e1d 100644 --- a/tp_note_2023_2024/src/requestHandlers/task.ts +++ b/tp_note_2023_2024/src/requestHandlers/task.ts @@ -26,4 +26,17 @@ export async function delete_one(req: Request, res: Response) { throw new HttpError("Task doesn't exist", 404); } responde(res, 204, "Task succesfully deleted."); +} + +export async function get_assignees(req: Request, res: Response) { + const task = await prisma.task.findUnique({ + where: { id: Number(req.params.task_id) }, + include: { + assignees: true, + }, + }); + if (task == null) { + throw new HttpError("Task doesn't exist", 404); + } + res.status(200).json(task.assignees); } \ No newline at end of file diff --git a/tp_note_2023_2024/src/routes/routes_tasks.ts b/tp_note_2023_2024/src/routes/routes_tasks.ts index d4d0b44..7536dd1 100644 --- a/tp_note_2023_2024/src/routes/routes_tasks.ts +++ b/tp_note_2023_2024/src/routes/routes_tasks.ts @@ -5,5 +5,6 @@ var ex = require("express"), router.patch("/:task_id", task.update_one); router.delete("/:task_id", task.delete_one); +router.get("/:task_id/asignees", task.get_assignees); module.exports = router; -- GitLab