Created
December 17, 2018 22:49
-
-
Save ahikmatf/d729046dc7c2d5785f598977abe88fdf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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