extend getSiteConfig to use directory
This commit is contained in:
parent
648c136fcf
commit
3d0170368e
|
@ -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/var/com.daplie.walnut.config.sqlite3
|
||||||
/srv/walnut/config/<domain.tld>.json
|
/srv/walnut/config/<domain.tld>/config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
Deleting those files will rese
|
Deleting those files will rese
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
var PromiseA = apiDeps.Promise;
|
var PromiseA = apiDeps.Promise;
|
||||||
|
var mkdirpAsync = PromiseA.promisify(require('mkdirp'));
|
||||||
//var express = require('express');
|
//var express = require('express');
|
||||||
var express = require('express-lazy');
|
var express = require('express-lazy');
|
||||||
var fs = PromiseA.promisifyAll(require('fs'));
|
var fs = PromiseA.promisifyAll(require('fs'));
|
||||||
|
@ -56,9 +57,12 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSiteConfig(clientUrih) {
|
function getSiteConfig(clientUrih) {
|
||||||
return fs.readFileAsync(path.join(xconfx.appConfigPath, clientUrih + '.json'), 'utf8').then(function (text) {
|
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);
|
return JSON.parse(text);
|
||||||
}).then(function (data) { return data; }, function (/*err*/) { return {}; });
|
}).then(function (data) { return data; }, function (/*err*/) { return {}; });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadRestHelper(myConf, pkgId) {
|
function loadRestHelper(myConf, pkgId) {
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
"mime": "^1.3.4",
|
"mime": "^1.3.4",
|
||||||
"mime-db": "^1.8.0",
|
"mime-db": "^1.8.0",
|
||||||
"mime-types": "^2.0.10",
|
"mime-types": "^2.0.10",
|
||||||
|
"mkdirp": "^0.5.1",
|
||||||
"ms": "^0.7.0",
|
"ms": "^0.7.0",
|
||||||
"native-dns": "^0.7.0",
|
"native-dns": "^0.7.0",
|
||||||
"negotiator": "^0.5.1",
|
"negotiator": "^0.5.1",
|
||||||
|
|
Loading…
Reference in New Issue