salix/services/print/application/config.js

29 lines
821 B
JavaScript

require('require-yaml');
const fs = require('fs-extra');
let configPath = '/config';
let nginxConfigPath = '/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 = `${__dirname}/config/datasources.${env}.json`;
if (fs.existsSync(configEnvFile))
Object.assign(config, require(configEnvFile));
let proxyConf = require(`${nginxConfigPath}/config.yml`);
let proxyEnvFile = `../../nginx/config.${env}.yml`;
if (fs.existsSync(proxyEnvFile))
Object.assign(proxyConf, require(proxyEnvFile));
config.proxy = proxyConf;
config.package = require('../package.json');
config.env = env;
module.exports = config;