From 1b6721d24225d3a50ff625345fe5ed2ea2feaadb Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 24 Nov 2021 01:07:29 +0100 Subject: [PATCH] Implemented env defaults and checking --- src/main.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main.js b/src/main.js index 321de75..152f6c8 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,25 @@ const log4js = require("log4js"); +const { requireEnvVars } = require("./helper/env.js"); /// Setup logger const logger = log4js.getLogger("main"); logger.level = process.env.logLevel ?? "INFO"; +/// Setup ENVs +const env = process.env; +// Defaults +{ + env.WIFI_INTERFACE ??= "wlan0"; + env.WIFI_CHANNEL ??= [1,6,11]; + env.WIFI_CHANNEL_TIME ??= 1; +} +// Required vars +let errorMsg = requireEnvVars([ + "INFLUX_URL", "INFLUX_TOKEN", + "INFLUX_ORG", "INFLUX_BUCKET" +]); +if(errorMsg){ + logger.fatal(errorMsg); + exit(1); +}