extend getSiteConfig to use directory

This commit is contained in:
AJ ONeal 2017-05-26 20:23:17 +00:00
parent 648c136fcf
commit 3d0170368e
3 changed files with 9 additions and 4 deletions

View File

@ -131,7 +131,7 @@ Once you run the app the initialization files will appear in these locations
```
/srv/walnut/var/com.daplie.walnut.config.sqlite3
/srv/walnut/config/<domain.tld>.json
/srv/walnut/config/<domain.tld>/config.json
```
Deleting those files will rese

View File

@ -2,6 +2,7 @@
module.exports.create = function (xconfx, apiFactories, apiDeps) {
var PromiseA = apiDeps.Promise;
var mkdirpAsync = PromiseA.promisify(require('mkdirp'));
//var express = require('express');
var express = require('express-lazy');
var fs = PromiseA.promisifyAll(require('fs'));
@ -56,9 +57,12 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
}
function getSiteConfig(clientUrih) {
return fs.readFileAsync(path.join(xconfx.appConfigPath, clientUrih + '.json'), 'utf8').then(function (text) {
return JSON.parse(text);
}).then(function (data) { return data; }, function (/*err*/) { return {}; });
var siteConfigPath = path.join(xconfx.appConfigPath, clientUrih);
return mkdirpAsync(siteConfigPath).then(function () {
return fs.readFileAsync(path.join(siteConfigPath, 'config.json'), 'utf8').then(function (text) {
return JSON.parse(text);
}).then(function (data) { return data; }, function (/*err*/) { return {}; });
});
}
function loadRestHelper(myConf, pkgId) {

View File

@ -89,6 +89,7 @@
"mime": "^1.3.4",
"mime-db": "^1.8.0",
"mime-types": "^2.0.10",
"mkdirp": "^0.5.1",
"ms": "^0.7.0",
"native-dns": "^0.7.0",
"negotiator": "^0.5.1",