From a8494ad38251ab9759b958f5c5d617c6def523d0 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Wed, 12 Feb 2025 14:22:16 +0100 Subject: [PATCH] =?UTF-8?q?Supprimer=20la=20configuration=20locale=20de=20?= =?UTF-8?q?la=20connexion=20=C3=A0=20la=20base=20de=20donn=C3=A9es=20et=20?= =?UTF-8?q?nettoyer=20le=20code=20de=20la=20route=20de=20t=C3=A9l=C3=A9cha?= =?UTF-8?q?rgement=20d'images?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.js | 8 +++--- routes/uploadRoutes.js | 55 ------------------------------------------ 2 files changed, 3 insertions(+), 60 deletions(-) diff --git a/db.js b/db.js index 02fc70c..7483067 100644 --- a/db.js +++ b/db.js @@ -1,10 +1,8 @@ const { Client } = require('pg'); -const local = false; -// Connexion à la base de données PostgreSQL const client = new Client({ - host: local ? 'mikoshi' : '172.30.0.2', - port: local ? 54322 : 5432, + host: '172.30.0.2', + port: 5432, user: 'timelapse', password: 'timelapse', database: 'timelapse' @@ -14,7 +12,7 @@ function connectWithRetry() { client.connect(err => { if (err) { console.error('Erreur de connexion à la base de données:', err); - setTimeout(connectWithRetry, 30000); // Réessayer après 30 secondes + setTimeout(connectWithRetry, 30000); } else { console.log('[DB] Connecté à la base de données PostgreSQL.'); } diff --git a/routes/uploadRoutes.js b/routes/uploadRoutes.js index a8615ae..25b5907 100644 --- a/routes/uploadRoutes.js +++ b/routes/uploadRoutes.js @@ -6,61 +6,6 @@ const serverError = require('../utils/serverError'); const upload = multer({ storage: multer.memoryStorage() }); -/** - * @swagger - * /upload: - * post: - * summary: Télécharger une image - * description: Télécharge une image pour un projet et un ordre spécifiques. - * requestBody: - * content: - * multipart/form-data: - * schema: - * type: object - * properties: - * image: - * type: string - * format: binary - * description: Fichier image à télécharger - * projectId: - * type: integer - * description: ID du projet - * orderId: - * type: integer - * description: ID de la commande - * responses: - * 200: - * description: Image téléchargée avec succès. - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string - * path: - * type: string - * 400: - * description: Tous les champs sont requis. - * 500: - * description: Erreur serveur. - */ -router.post('/upload', upload.single('image'), async (req, res) => { - const { projectId, orderId } = req.body; - const image = req.file; - - if (!image || !projectId || !orderId) { - return res.status(400).json({ error: 'All fields are required' }); - } - - try { - const imagePath = await measureManager.uploadMeasureImage(image, projectId, orderId); - res.json({ message: 'Image uploaded successfully', path: imagePath }); - } catch (error) { - serverError.sendError('Error uploading image:', res, error); - } -}); - /** * @swagger * /uploadmeasurement: