Добавлена папка config
This commit is contained in:
21
server/config/base.js
Normal file
21
server/config/base.js
Normal 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
18
server/config/config.js
Normal 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);
|
||||
6
server/config/development.js
Normal file
6
server/config/development.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const base = require('./base');
|
||||
|
||||
module.exports = Object.assign({}, base, {
|
||||
branch: 'development',
|
||||
}
|
||||
);
|
||||
6
server/config/production.js
Normal file
6
server/config/production.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const base = require('./base');
|
||||
|
||||
module.exports = Object.assign({}, base, {
|
||||
branch: 'production',
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user