forked from Hypfer/ICantBelieveItsNotValetudo
-
Notifications
You must be signed in to change notification settings - Fork 18
/
app.js
40 lines (36 loc) · 1.43 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Configuration = require("./lib/Configuration");
const MqttClient = require("./lib/MqttClient");
const WebServer = require("./lib/Webserver");
const EventEmitter = require('events');
const args = process.argv.slice(2);
const options = {
customConfigCreate: args.includes('-c'),
customConfigPath: args.includes('-f') && args[args.indexOf('-f') + 1] || null
};
const conf = new Configuration(options);
const events = new EventEmitter();
if(conf.get("mqtt")) {
new MqttClient({
brokerURL: conf.get("mqtt").broker_url,
caPath: conf.get("mqtt").caPath,
identifier: conf.get("mqtt").identifier,
deviceName: conf.get("mqtt").deviceName,
topicPrefix: conf.get("mqtt").topicPrefix,
autoconfPrefix: conf.get("mqtt").autoconfPrefix,
mapSettings: conf.get("mapSettings"),
mapDataTopic: conf.get("mqtt").mapDataTopic,
minMillisecondsBetweenMapUpdates: conf.get("mqtt").minMillisecondsBetweenMapUpdates,
publishMapImage: conf.get("mqtt").publishMapImage,
publishMapData: conf.get("mqtt").publishMapData,
webserverEnabled: conf.get("webserver") && conf.get("webserver").enabled === true,
events: events
});
if(conf.get("webserver") && conf.get("webserver").enabled === true) {
new WebServer({
port: conf.get("webserver").port,
events: events
})
}
} else {
console.error("Missing configuration.mqtt");
}