To prevent passwords, database connection urls, and other secrets from being exposed, it is considered bad practice to commit these things in code. However, this means that whenever we pull code from git, we have to manually enter these values in the code to make it work.
The way we solve this problem is by creating a separate file (usually a .env) file which keeps all these environment variables and passwords, and we simply load them into the code using process.env.PASSWORD_NAME.
We should add support for this in our API repo. The npm package to load is called dotenv. You can learn more about how to use it here: https://www.npmjs.com/package/dotenv
Also, please add the .env file to .gitignore so it doesn't get committed
To prevent passwords, database connection urls, and other secrets from being exposed, it is considered bad practice to commit these things in code. However, this means that whenever we pull code from git, we have to manually enter these values in the code to make it work.
The way we solve this problem is by creating a separate file (usually a
.env
) file which keeps all these environment variables and passwords, and we simply load them into the code usingprocess.env.PASSWORD_NAME
.We should add support for this in our API repo. The npm package to load is called
dotenv
. You can learn more about how to use it here: https://www.npmjs.com/package/dotenvAlso, please add the
.env
file to.gitignore
so it doesn't get committed