Добавлена папка config

This commit is contained in:
Book Pauk
2018-12-26 21:03:45 +07:00
parent 1ce0e6da10
commit 279e4cd9ed
4 changed files with 51 additions and 0 deletions

21
server/config/base.js Normal file
View File

@@ -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,
};

18
server/config/config.js Normal file
View File

@@ -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);

View File

@@ -0,0 +1,6 @@
const base = require('./base');
module.exports = Object.assign({}, base, {
branch: 'development',
}
);

View File

@@ -0,0 +1,6 @@
const base = require('./base');
module.exports = Object.assign({}, base, {
branch: 'production',
}
);