2018-02-04 18:39:56 +00:00
|
|
|
require('require-yaml');
|
2018-05-28 10:22:35 +00:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
let configPath = '/config';
|
|
|
|
let nginxConfigPath = '/nginx';
|
2017-11-27 14:08:18 +00:00
|
|
|
|
2018-02-03 21:53:02 +00:00
|
|
|
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
2017-11-27 14:08:18 +00:00
|
|
|
|
2018-05-28 10:22:35 +00:00
|
|
|
if (env === 'development') {
|
|
|
|
configPath = `${__dirname}/config`;
|
|
|
|
nginxConfigPath = '../../nginx';
|
|
|
|
}
|
|
|
|
|
|
|
|
let config = require(`${configPath}/datasources.json`);
|
2018-02-03 21:53:02 +00:00
|
|
|
let configEnvFile = `${__dirname}/config/datasources.${env}.json`;
|
2018-01-29 11:37:54 +00:00
|
|
|
|
2018-02-03 21:53:02 +00:00
|
|
|
if (fs.existsSync(configEnvFile))
|
|
|
|
Object.assign(config, require(configEnvFile));
|
2017-12-27 08:44:27 +00:00
|
|
|
|
2018-05-28 10:22:35 +00:00
|
|
|
let proxyConf = require(`${nginxConfigPath}/config.yml`);
|
2018-02-04 18:39:56 +00:00
|
|
|
let proxyEnvFile = `../../nginx/config.${env}.yml`;
|
2017-11-27 14:08:18 +00:00
|
|
|
|
2018-02-03 21:53:02 +00:00
|
|
|
if (fs.existsSync(proxyEnvFile))
|
|
|
|
Object.assign(proxyConf, require(proxyEnvFile));
|
|
|
|
|
|
|
|
config.proxy = proxyConf;
|
2017-11-27 14:08:18 +00:00
|
|
|
config.package = require('../package.json');
|
2018-05-28 10:22:35 +00:00
|
|
|
config.env = env;
|
2017-11-27 14:08:18 +00:00
|
|
|
|
2018-05-28 10:22:35 +00:00
|
|
|
module.exports = config;
|