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