Allow local config.json to overwrite defaults.
This commit is contained in:
parent
ddb629c320
commit
1aba5ccd2e
3 changed files with 18 additions and 7 deletions
|
@ -6,6 +6,7 @@
|
|||
"devDependencies": {
|
||||
"body-parser": "~1.3.0",
|
||||
"compression": "~1.0.6",
|
||||
"deep-extend": "~0.2.10",
|
||||
"express": "~4.4.1",
|
||||
"glob": "~4.0.2",
|
||||
"grunt": "~0.4.1",
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng').factory('config', function () {
|
||||
return {
|
||||
angular.module('ffffng').factory('config', function (fs, deepExtend) {
|
||||
var defaultConfig = {
|
||||
server: {
|
||||
port: 8080,
|
||||
peersPath: '/tmp/peers'
|
||||
},
|
||||
client: {
|
||||
community: {
|
||||
name: 'Freifunk Hamburg',
|
||||
domain: 'hamburg.freifunk.net',
|
||||
contactEmail: 'kontakt@hamburg.freifunk.net'
|
||||
name: 'Freifunk Musterstadt',
|
||||
domain: 'musterstadt.freifunk.net',
|
||||
contactEmail: 'kontakt@musterstadt.freifunk.net'
|
||||
},
|
||||
map: {
|
||||
graphUrl: 'http://graph.hamburg.freifunk.net/graph.html',
|
||||
mapUrl: 'http://graph.hamburg.freifunk.net/geomap.html'
|
||||
graphUrl: 'http://graph.musterstadt.freifunk.net/graph.html',
|
||||
mapUrl: 'http://graph.musterstadt.freifunk.net/geomap.html'
|
||||
},
|
||||
coordsSelector: {
|
||||
lat: 53.565278,
|
||||
|
@ -23,4 +23,13 @@ angular.module('ffffng').factory('config', function () {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
var configJSONFile = __dirname + "/../config.json";
|
||||
var configJSON = undefined;
|
||||
|
||||
if (fs.existsSync(configJSONFile)) {
|
||||
configJSON = JSON.parse(fs.readFileSync(configJSONFile, 'utf8'));
|
||||
}
|
||||
|
||||
return deepExtend({}, defaultConfig, configJSON);
|
||||
});
|
||||
|
|
|
@ -17,4 +17,5 @@
|
|||
lib('crypto');
|
||||
lib('fs');
|
||||
lib('glob');
|
||||
lib('deepExtend', 'deep-extend');
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue