mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:57:08 +00:00
Read also global config in server backend.
The configuration file etc/config.yaml is exposed to the
server backend under require('configuration').global.
Note that at some point it will probably make sense to
merge the two config files.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const YAML = require('yaml');
|
||||
|
||||
const cfgPrefix = process.env.DOUGAL_ROOT || ((process.env.HOME || ".") + "/software");
|
||||
const cfgPath = process.env.DOUGAL_API_CONFIG || (cfgPrefix+"/etc/www/config.json");
|
||||
const globalCfgPath = cfgPrefix+"/etc/config.yaml";
|
||||
|
||||
let config = {}
|
||||
|
||||
@@ -51,6 +53,13 @@ try {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fs.existsSync(globalCfgPath)) {
|
||||
const text = fs.readFileSync(globalCfgPath, 'utf8');
|
||||
if (text) {
|
||||
config.global = YAML.parse(text);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
5
lib/www/server/package-lock.json
generated
5
lib/www/server/package-lock.json
generated
@@ -613,6 +613,11 @@
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
|
||||
},
|
||||
"yaml": {
|
||||
"version": "2.0.0-0",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-0.tgz",
|
||||
"integrity": "sha512-+n+AwzE2hK2j21p36UB2foND6RYQU4PQkdPCK4YF2OKz8BbiNI+NvKS79CpyDChw3k/0L9jnChkjEzKoiu2C7w=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"express": "^4.17.1",
|
||||
"express-jwt": "^6.0.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"pg": "^8.3.0"
|
||||
"pg": "^8.3.0",
|
||||
"yaml": "^2.0.0-0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user