Skip to content

Commit

Permalink
Reorganise configuration and move it to env's
Browse files Browse the repository at this point in the history
  • Loading branch information
alinetskyi committed Jul 29, 2019
1 parent 4e436a2 commit 6e8f77a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 8 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ const config = require('./config.json');
const defaultConfig = config.development;
const environment = process.env.NODE_ENV || 'development';
const environmentConfig = config[environment];
const finalConfig = _.merge(defaultConfig, environmentConfig);

// set up config from env's
environmentConfig.barong_url = process.env.BARONG_URL || 'http://localhost:3000/api/v2/management/users/get';
environmentConfig.jwt.expire_date = process.env.JWT_EXPIRE_DATE || 60;
environmentConfig.jwt.algorithm = process.env.JWT_ALGORITHM || 'RS256';
environmentConfig.jwt.private_key = process.env.JWT_PRIVATE_KEY;
environmentConfig.node_port = process.env.PORT || defaultConfig.node_port;

const finalConfig = _.merge(defaultConfig, environmentConfig);
// as a best practice
// all global variables should be referenced via global. syntax
// and their names should always begin with g
Expand Down
9 changes: 2 additions & 7 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"development": {
"config_id": "development",
"app_name": "Nodelogic",
"app_desc": "my app desc",
"app_desc": "Node JS Applogic for Rubykube Stack",
"node_port": 3001,
"json_indentation": 4,
"barong_url": "http://localhost:3000/api/v2/management/users/get",
Expand All @@ -12,15 +12,10 @@
"private_key": "private_key_in_base64"
}
},
"testing": {
"test": {
"config_id": "testing",
"database": "my-app-db-test"
},
"staging": {
"config_id": "staging",
"node_port": 8080,
"database": "my-app-db-stag"
},
"production": {
"config_id": "production",
"node_port": 8080,
Expand Down

0 comments on commit 6e8f77a

Please sign in to comment.