What about to use dotenv for MongoDB connection string?
nicetomytyuk opened this issue · comments
This can help other users which has problems by setting the environment variable for the MongoDB. By setting the env with powershell or Windows GUI the default connection string is set all the times so i needed to use dotenv to set the custom one.
By trying to make my connection string work i've used the dotenv for settings and reading the environmental variable so once dotenv is installed
npm install dotenv
i've created a .env
file in my root project with the following content:
#MongoDB Connection String
VC19_MONGODB_URL=mongodb://root:example@localhost:27017/VC19?authSource=admin
And set this in crl.js or as soon as the application runs (ex: app.js):
require('dotenv').config()
Sounds great @nicetomytyuk! Yeah nothing against dotenv, we could set it as a standard. Would you like to open a PR to implement it by default?