Refactor la récupération des projets pour utiliser un modèle et améliore les messages d'erreur en français
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user