diff --git a/lib/core/config.js b/lib/core/config.js index ad4f4d5b..3db31a9a 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -95,7 +95,18 @@ Config.prototype.loadContractsConfigFile = function() { Config.prototype.loadStorageConfigFile = function() { - var configObject = {}; + var configObject = { + "default": { + "enabled": true, + "available_providers": ["ipfs"], + "ipfs_bin": "ipfs", + "provider": "ipfs", + "host": "localhost", + "port": 5001 + }, + "development": { + } + }; //var configPlugins = this.plugins.getPluginsFor('storageConfig'); //if (configPlugins.length > 0) { @@ -106,8 +117,12 @@ Config.prototype.loadStorageConfigFile = function() { // }); //} - var storageConfig = fs.readJSONSync(this.configDir + "storage.json"); - configObject = utils.recursiveMerge(configObject, storageConfig); + var storageConfig; + if (fs.existsSync(this.configDir + "storage.json")) { + storageConfig = fs.readJSONSync(this.configDir + "storage.json"); + configObject = utils.recursiveMerge(configObject, storageConfig); + } + var defaultStorageConfig = configObject['default']; var envStorageConfig = configObject[this.env]; @@ -123,7 +138,13 @@ Config.prototype.loadStorageConfigFile = function() { }; Config.prototype.loadCommunicationConfigFile = function() { - var configObject = {}; + var configObject = { + "default": { + "enabled": true, + "provider": "whisper", + "available_providers": ["whisper", "orbit"] + } + }; //var configPlugins = this.plugins.getPluginsFor('communicationConfig'); //if (configPlugins.length > 0) { @@ -134,14 +155,20 @@ Config.prototype.loadCommunicationConfigFile = function() { // }); //} - var communicationConfig = fs.readJSONSync(this.configDir + "communication.json"); - configObject = utils.recursiveMerge(configObject, communicationConfig); + var communicationConfig; + + if (fs.existsSync(this.configDir + "communication.json")) { + communicationConfig = fs.readJSONSync(this.configDir + "communication.json"); + configObject = utils.recursiveMerge(configObject, communicationConfig); + } + var defaultCommunicationConfig = configObject['default']; var envCommunicationConfig = configObject[this.env]; var mergedConfig = utils.recursiveMerge(defaultCommunicationConfig, envCommunicationConfig); this.communicationConfig = mergedConfig || {}; + // TODO: probably not necessary if the default object is done right if (this.communicationConfig.enabled === undefined) { this.communicationConfig.enabled = true; } @@ -151,7 +178,12 @@ Config.prototype.loadCommunicationConfigFile = function() { }; Config.prototype.loadWebServerConfigFile = function() { - var webServerConfigJSON = fs.readJSONSync(this.configDir + "webserver.json"); + var webServerConfigJSON; + if (fs.existsSync(this.configDir + "webserver.json")) { + webServerConfigJSON = fs.readJSONSync(this.configDir + "webserver.json"); + } else { + webServerConfigJSON = {}; + } var defaultWebConfig = { "enabled": true, "host": "localhost",