vega-frontend-monorepo/apps/trading/lib/config/env.ts
botond 46884e3fec
fix: cleanup more env things (#1383)
* fix: remove vega_rest from monorepo
* fix: mainnet api urls
* fix: remove redundant vega url from token config
* fix: lint
* chore: remove redundant env props from token app
* fix: format
2022-09-18 11:15:05 +00:00

21 lines
605 B
TypeScript

const windowOrDefault = (key: string, defaultValue?: string) => {
if (typeof window !== 'undefined') {
if (window._env_ && window._env_[key]) {
return window._env_[key];
}
}
return defaultValue || '';
};
/**
* Need to have default value as next in-lines environment variables. Cannot figure out dynamic keys.
* So must provide the default with the key so that next can figure it out.
*/
export const ENV = {
envName: windowOrDefault('NX_VEGA_ENV', process.env['NX_VEGA_ENV']),
dsn: windowOrDefault(
'NX_TRADING_SENTRY_DSN',
process.env['NX_TRADING_SENTRY_DSN']
),
};