]> git.digitality.be Git - pdw25-26/commitdiff
Correction route BotService
authorSacheat <sacha.libion@outlook.com>
Sun, 1 Mar 2026 20:51:09 +0000 (21:51 +0100)
committerSacheat <sacha.libion@outlook.com>
Sun, 1 Mar 2026 20:51:09 +0000 (21:51 +0100)
Wallette/server/modules/strategy/services/BotService.js

index 66352718bca1bbd2f88124722dec404e7c72af31..d1b1f2e672d0c825b04355e6a1d228bd58062306 100644 (file)
@@ -84,24 +84,32 @@ class BotService {
 
     async sendToAlertsModule(signalPayload) {
         try {
+            
+            const BROADCAST_URL = 'http://127.0.0.1:3003/test/broadcast-alert';
+
             const response = await fetch(
-                `${ALERTS_URL}/api/alerts/process-signal`,
+                BROADCAST_URL,
                 {
                     method: 'POST',
                     headers: { 'Content-Type': 'application/json' },
                     body: JSON.stringify(signalPayload)
                 }
             );
+
             if (!response.ok) {
-                const err = await response.json();
-                console.error('Module Alertes a refusé le signal :', err);
+                // Parfois les routes de test ne renvoient pas de JSON propre sur les erreurs,
+                // on gère ça prudemment en lisant le texte brut.
+                const errText = await response.text();
+                console.error(`Module Alertes a refusé le signal (Statut ${response.status}) :`, errText);
                 return;
             }
+
             const result = await response.json();
-            console.log('Signal envoyé au module Alertes :', result.data);
+            console.log('📡 Signal diffusé en temps réel au module Alertes !', result);
+
         } catch (error) {
-            // Si alertes-service est éteint, le bot continue quand même
-            console.error('Impossible de joindre le module Alertes :', error.message);
+            // Si alertes-service est éteint, le bot continue quand même (Génial ça !)
+            console.error('Impossible de joindre le module Alertes (Port 3003 éteint ou inaccessible) :', error.message);
         }
     }