Refactor la route GET /projects pour utiliser async/await et améliorer la gestion des erreurs

This commit is contained in:
2025-01-14 17:47:07 +01:00
parent 872218882e
commit f503f224a6

View File

@@ -18,7 +18,15 @@ const fileUtils = require('../fileUtils');
* 500: * 500:
* description: Internal server error * description: Internal server error
*/ */
router.get('/projects', projectController.getAllProjects); router.get('/projects', async (req, res) => {
try {
const projects = await db.query('SELECT * FROM public.projects');
res.json(projects.rows);
} catch (error) {
console.error('Error fetching projects:', error);
res.status(500).json({ error: 'Internal server error' });
}
});
/** /**
* @swagger * @swagger