salix/services/mailer/application/config.js

30 lines
870 B
JavaScript

require('require-yaml');
const fs = require('fs-extra');
const package = require('../package.json');
let configPath = `/config/${package.name}`;
let nginxConfigPath = '/config/nginx';
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
if (env === 'development') {
configPath = `${__dirname}/config`;
nginxConfigPath = '../../nginx';
}
let config = require(`${configPath}/datasources.json`);
let configEnvFile = `${configPath}/datasources.${env}.json`;
if (fs.existsSync(configEnvFile))
Object.assign(config, require(configEnvFile));
let proxyConf = require(`${nginxConfigPath}/config.yml`);
let proxyEnvFile = `${nginxConfigPath}/config.${env}.yml`;
if (fs.existsSync(proxyEnvFile))
Object.assign(proxyConf, require(proxyEnvFile));
config.proxy = proxyConf;
config.package = package;
config.env = env;
module.exports = config;