diff --git a/.env.example b/.env.example index bc8c75e2ebefb7b0ee069f58a4b70b3feb6b98ce..7291206ba3a80889ea1966ed0768507758de5101 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,8 @@ +MQTT_HOST= +MQTT_PORT= + MQTT_USER= MQTT_PASS= + +HTTP_BIND= +HTTP_PORT= diff --git a/main.js b/main.js index a4abe1b530edd4171f928a199ce3392bc383d2db..cf523757a29442ec0a323ed4480993b265f1e1cb 100644 --- a/main.js +++ b/main.js @@ -2,10 +2,11 @@ const mqtt = require('mqtt'); const http = require('http'); const fs = require('node:fs'); -const web_host = 'localhost'; -const web_port = 5000; +const web_host = process.env.HTTP_BIND; +const web_port = process.env.HTTP_PORT; -const mqtt_url = 'mqtt://130.95.13.152:1883'; +const mqtt_host = process.env.MQTT_HOST; +const mqtt_port = process.env.MQTT_PORT; // Create an MQTT client instance const options = { @@ -16,7 +17,7 @@ const options = { password: process.env.MQTT_PASS, }; -const client = mqtt.connect(mqtt_url, options); +const client = mqtt.connect(`mqtt://${mqtt_host}:${mqtt_port}`, options); client.on('connect', () => { console.log('Connected!');