From cb73a1ca3f0ef66b9444c79dbbdffc0051121860 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Tue, 11 Feb 2025 10:51:59 +0100 Subject: [PATCH] =?UTF-8?q?Refactor=20la=20r=C3=A9cup=C3=A9ration=20des=20?= =?UTF-8?q?projets=20pour=20utiliser=20un=20mod=C3=A8le=20et=20am=C3=A9lio?= =?UTF-8?q?re=20les=20messages=20d'erreur=20en=20fran=C3=A7ais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/routes/api.js b/routes/api.js index 71c2834..2110661 100644 --- a/routes/api.js +++ b/routes/api.js @@ -94,13 +94,13 @@ router.get('/projects/:id', async (req, res) => { return res.status(400).json({ error: 'Invalid project ID' }); } try { - const project = await db.query('SELECT * FROM public.projects WHERE id = $1', [projectId]); - if (project.rows.length === 0) { - return res.status(404).json({ error: 'Project not found' }); + const project = await projectModel.getProjectById(db, projectId); + if (!project) { + return res.status(404).json({ error: 'Projet non trouvé' }); } - res.json(project.rows[0]); + res.json(project); } catch (error) { - serverError.sendError('Error getting project:', res, error); + serverError.sendError('Erreur lors de la récupération du projet:', res, error); } }); @@ -547,6 +547,14 @@ router.get('/smile', (req, res) => { * /image/{filename}: * get: * description: Use to request a specific image by filename + * parameters: + * - in: path + * name: filename + * required: true + * description: Name of the image file to retrieve. + * schema: + * type: string + * example: image.jpg * responses: * 200: * description : A successful response