diff --git a/server/config/base.js b/server/config/base.js new file mode 100644 index 00000000..eb5d63f6 --- /dev/null +++ b/server/config/base.js @@ -0,0 +1,21 @@ +const path = require('path'); +const fs = require('fs'); + +const packageObj = JSON.parse(fs.readFileSync(__dirname + '/../../package.json', 'utf8')); +const execPath = path.dirname(process.execPath); + +module.exports = { + branch: 'base', + tempDir: execPath +'/tmp', + logDir: execPath + '/log', + dataDir: execPath + '/data', + dbFileName: 'db.sqlite', + loggingEnabled: true, + + port: '33080', + ip: '127.0.0.1', + + version: packageObj.version, + name: packageObj.name, +}; + diff --git a/server/config/config.js b/server/config/config.js new file mode 100644 index 00000000..09b1b50f --- /dev/null +++ b/server/config/config.js @@ -0,0 +1,18 @@ +const fs = require('fs'); + +const branchFilename = __dirname + '/../application_env'; + +let branch = 'production'; +try { + fs.accessSync(branchFilename); + branch = fs.readFileSync(branchFilename, 'utf8').trim(); +} catch (err) { +} + +process.env.NODE_ENV = branch; + +const confFilename = __dirname + `/${branch}.js`; + +fs.accessSync(confFilename); + +module.exports = require(confFilename); \ No newline at end of file diff --git a/server/config/development.js b/server/config/development.js new file mode 100644 index 00000000..a7e5f125 --- /dev/null +++ b/server/config/development.js @@ -0,0 +1,6 @@ +const base = require('./base'); + +module.exports = Object.assign({}, base, { + branch: 'development', + } +); diff --git a/server/config/production.js b/server/config/production.js new file mode 100644 index 00000000..2edf1471 --- /dev/null +++ b/server/config/production.js @@ -0,0 +1,6 @@ +const base = require('./base'); + +module.exports = Object.assign({}, base, { + branch: 'production', + } +);