Skip to content

Instantly share code, notes, and snippets.

@ahikmatf
Created December 17, 2018 22:49
Show Gist options
  • Select an option

  • Save ahikmatf/d729046dc7c2d5785f598977abe88fdf to your computer and use it in GitHub Desktop.

Select an option

Save ahikmatf/d729046dc7c2d5785f598977abe88fdf to your computer and use it in GitHub Desktop.
https://hackernoon.com/the-practical-guide-for-building-rest-api-in-nodejs-and-mongodb-include-passport-and-jwt-476720b70da0
const devConfig = {};
const testConfig = {};
const prodConfig = {};
const defaultConfig = {
PORT: process.env.PORT || 3000,
};
function envConfig(env) {
switch (env) {
case 'development':
return devConfig;
case 'test':
return testConfig;
default:
return prodConfig;
}
}
//Take defaultConfig and make it a single object
//So, we have concatenated two objects into one
export default { ...defaultConfig,
...envConfig(process.env.NODE_ENV),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment