Skip to content

Instantly share code, notes, and snippets.

@iest
Last active November 25, 2015 10:43
Show Gist options
  • Save iest/139b2bc37761262ba948 to your computer and use it in GitHub Desktop.
Save iest/139b2bc37761262ba948 to your computer and use it in GitHub Desktop.
Potential config...
import {canUseDOM} from 'exenv';
function getWhitelistedVars(global) {
return Object.keys(global).reduce((obj, key) => {
if (defaults.hasOwnProperty(key)) {
obj[key] = global[key];
}
return obj;
}, {});
}
const defaults = {
API_BASE: 'https://api.pactcoffee.com',
STRIPE_PUBLISHABLE_KEY: null,
NODE_ENV: 'development',
DISABLE_SSR: false,
PORT: 3000,
}
const globalConfig = canUseDOM ? window.CONFIG : process.env;
const config = {
...defaults,
...getWhitelistedVars(globalConfig),
};
import {API_BASE} from 'config';
// do stuff with API_BASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment