mailer config

This commit is contained in:
Joan Sanchez 2019-01-15 08:56:30 +01:00
parent 76bfd0db7a
commit 68bc3f2c7b
1 changed files with 17 additions and 15 deletions

View File

@ -2,26 +2,28 @@ require('require-yaml');
const fs = require('fs-extra');
const packageJson = require('../package.json');
let configPath = `/etc/${packageJson.name}`;
let nginxConfigPath = configPath;
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let config = require('./config/datasources.json');
let configFiles = [
`${configPath}/datasources.json`,
`${configPath}/datasources.${env}.json`
];
if (env === 'development') {
configPath = `${__dirname}/config`;
nginxConfigPath = '../../nginx';
for (let configFile of configFiles) {
if (fs.accessSync(configFile))
Object.assign(config, require(configFile));
}
let config = require(`${configPath}/datasources.json`);
let configEnvFile = `${configPath}/datasources.${env}.json`;
let proxyConf = require('../../nginx/config.yml');
let proxyFiles = [
`${configPath}/config.yml`,
`${configPath}/config.${env}.yml`
];
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));
for (let proxyFile of proxyFiles) {
if (fs.accessSync(proxyFile))
Object.assign(proxyConf, require(proxyFile));
}
config.proxy = proxyConf;
config.package = packageJson;