diff --git a/.gitignore b/.gitignore index 8ee54e8..3d551ca 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ coverage *.sw? *.tsbuildinfo + +# Local configuration file +/src/config.js \ No newline at end of file diff --git a/src/config.js.example b/src/config.js.example new file mode 100644 index 0000000..559f60b --- /dev/null +++ b/src/config.js.example @@ -0,0 +1,4 @@ +// config.js +export default { + mqttBrokerUrl: 'ws://localhost:9001' +}; diff --git a/src/services/mqttService.js b/src/services/mqttService.js index 08389f3..ce3a9ac 100644 --- a/src/services/mqttService.js +++ b/src/services/mqttService.js @@ -1,7 +1,9 @@ import mqtt from 'mqtt'; +import config from '@/config.js'; +const mqttBrokerUrl = config.mqttBrokerUrl; // Créer une instance de client MQTT -const client = mqtt.connect('ws://localhost:9001'); +const client = mqtt.connect(mqttBrokerUrl); // Fonction pour publier un message sur un topic MQTT export function publishMessage(topic, message) {