salix/services/mailer/application/config.js

29 lines
821 B
JavaScript
Raw Normal View History

require('require-yaml');
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
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-02-03 21:53:02 +00:00
if (fs.existsSync(configEnvFile))
Object.assign(config, require(configEnvFile));
2017-12-27 08:44:27 +00:00
let proxyConf = require(`${nginxConfigPath}/config.yml`);
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');
config.env = env;
2017-11-27 14:08:18 +00:00
module.exports = config;