salix/services/print/application/config.js

30 lines
870 B
JavaScript
Raw Normal View History

require('require-yaml');
const fs = require('fs-extra');
2018-05-28 10:49:56 +00:00
const package = require('../package.json');
let configPath = `/config/${package.name}`;
let nginxConfigPath = '/config/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-05-28 10:49:56 +00:00
let configEnvFile = `${configPath}/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`);
2018-05-28 10:49:56 +00:00
let proxyEnvFile = `${nginxConfigPath}/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;
2018-05-28 10:49:56 +00:00
config.package = package;
config.env = env;
2017-11-27 14:08:18 +00:00
module.exports = config;