Created
April 18, 2019 19:49
-
-
Save webislife/555fa8bef285c7735f70bb9a5fbd0b90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console */ | |
"use strict"; | |
/** | |
* @module Configuration app variables by process.env | |
*/ | |
const ENV = process.env; | |
/** | |
* Application envoirment config | |
* @type {Object} | |
* @property {String} ENV env mode development\production | |
* @property {String} DIST dir path folder for webpack dist | |
* @property {String} API_BGLN_HOST host path for main biglion api | |
* @property {String} GOOGLE_RECAPTCHA_SITEKEY google key for recaptcha | |
* @property {String} GA_ID Google Analytics ID | |
* @property {String} GTM_ID Google tag manager ID | |
* @property {String} FB_ID Facebook Analytics ID | |
* @property {String} YA_METRIKA_ID Yandex metrika ID | |
* @property {String} VK_AUTH_CLIENT_ID client id for vk oauth | |
* @property {String} VK_AUTH_CLIENT_SECRET client secret for vk oauth | |
* @property {String} OK_AUTH_CLIENT_ID client secret for ok.ru oauth | |
* @property {String} GOOGLE_AUTH_CLIENT_ID client id for google oauth | |
* @property {String} MAILRU_AUTH_CLIENT_ID client id for mail.ru oauth | |
* @property {String} FB_AUTH_APP_ID client id for facebook oauth | |
*/ | |
const appConf = { | |
ENV: ENV.NODE_ENV || 'development', | |
NODE_ENV: ENV.NODE_ENV || 'development', | |
DIST: ENV.DIST || './../dist', | |
PUBLIC_PATH: ENV.PUBLIC_PATH || '/', | |
GATEWAY_PORT: ENV.GATEWAY_PORT || 8081, | |
SSR_PORT: ENV.SSR_PORT || 8080, | |
API_HOST: ENV.API_BGLN_HOST || 'http://DEV_BACKEND/', | |
GOOGLE_RECAPTCHA_SITEKEY: ENV.GOOGLE_RECAPTCHA_SITEKEY || '...', | |
GOOGLE_RECAPTCHA_SECRET: ENV.GOOGLE_RECAPTCHA_SECRET || '...', | |
GA_ID: ENV.GA_ID || '0', | |
GTM_ID: ENV.GA_ID || '...', | |
FB_ID: ENV.FB_ID || '...' | |
}; | |
/** | |
* Validate config fields | |
* @param {Object} config application | |
* @return {void} | |
*/ | |
function validateConf(config) { | |
for(let key in config) { | |
if(config[key] === undefined || config[key] === 'undefined' ) { | |
console.error(`ERROR: Undefined ${key} in application config. Build stopped.`); | |
process.exit(1); | |
} | |
} | |
} | |
validateConf(appConf); | |
console.info('App Configuration:'); | |
console.dir(appConf); | |
module.exports = appConf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment