diff --git a/README.md b/README.md index 3325e1f..8880adc 100644 --- a/README.md +++ b/README.md @@ -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/.json +/srv/walnut/config//config.json ``` Deleting those files will rese diff --git a/lib/apis.js b/lib/apis.js index fb65f9a..2203928 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -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) { diff --git a/package.json b/package.json index 9d06ed8..efa3ca0 100644 --- a/package.json +++ b/package.json @@ -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",