JSON (config file) with dynamic variables JSON (config file) with dynamic variables docker docker

JSON (config file) with dynamic variables


According to my understanding, better idea is to create a global config file like config.js, and put your configurations like

module.exports = {    // APP SETTINGS   ...   "host": process.env.DBHOST || 'localhost',   "port": process.env.DBPORT || '8080',   ...}; 

After doing this, you can easily access this file wherever you want.For e.g. if you want to access these configurations in app.js file, then simply include it by adding a line in app.js file

var config = require('./config');

This will make the values available under config namespace and the values can be accessed as :

config.host or config.port

Hope the answer tells what you wanted.. If your intention is something else then please comment..