1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-27 06:23:53 +01:00

minor fixes, code cleanup, accesibility features

This commit is contained in:
NoobishSVK
2024-02-16 00:26:40 +01:00
parent 5f45a069df
commit a2c73c396b
12 changed files with 108 additions and 80 deletions

View File

@@ -2,6 +2,14 @@
const fs = require('fs');
const { logDebug, logError, logInfo, logWarn } = require('./console');
let configName = 'config';
const index = process.argv.indexOf('--config');
if (index !== -1 && index + 1 < process.argv.length) {
configName = process.argv[index + 1];
logInfo('Loading with a custom config file:', configName + '.json')
}
let serverConfig = {
webserver: {
webserverIp: "0.0.0.0",
@@ -13,6 +21,11 @@ let serverConfig = {
xdrdPort: "7373",
xdrdPassword: ""
},
audio: {
audioDevice: "Microphone (High Definition Audio Device)",
audioChannels: 2,
audioBitrate: "128k"
},
identification: {
token: null,
tunerName: "",
@@ -27,7 +40,8 @@ let serverConfig = {
adminPass: ""
},
publicTuner: true,
lockToAdmin: false
lockToAdmin: false,
autoShutdown: false,
};
function deepMerge(target, source)
@@ -46,7 +60,7 @@ function configUpdate(newConfig) {
}
function configSave() {
fs.writeFile('config.json', JSON.stringify(serverConfig, null, 2), (err) => {
fs.writeFile(configName + '.json', JSON.stringify(serverConfig, null, 2), (err) => {
if (err) {
logError(err);
} else {
@@ -55,11 +69,11 @@ function configSave() {
});
}
if (fs.existsSync('config.json')) {
const configFileContents = fs.readFileSync('config.json', 'utf8');
if (fs.existsSync(configName + '.json')) {
const configFileContents = fs.readFileSync(configName + '.json', 'utf8');
serverConfig = JSON.parse(configFileContents);
}
module.exports = {
serverConfig, configUpdate, configSave
configName, serverConfig, configUpdate, configSave
};