Can we profile Javascript

I have a JS file containing some configuration code, for example:

module.exports = {
        database: {
            username: 'devusername',
            password: 'devpassword',
            host: 'xx.xx.xx.xx',
            port: 27017,
            name: 'admin'           
        }
};

      

Username, password, host, port and name can be changed according to the enviornment. As development , QA , production . Every time I change the environment, I need to change the JS file. Is there a way that I can combine all the details and get the values ​​from the corresponding environment.

Thank you in advance

+3


source to share


1 answer


You can set these parameters using environment variables and then capture them via process.env

. Thus, as long as the environment variables are named the same, you just need to provide the setting environment setting.



0


source







All Articles