I have 2 questions, and I am asking two questions together since it is related to each other.
I am using sequelize-cli for migration, (I used sync({force: true}) before)
when I use the command
sequelize init
the config/config.json is created, and that json file is structured in the way of key-value pair, development / test / production.
// like below
{
"development": {
},
"test": {
},
"production": {
}
}
Before using sequelize migration, I had no idea of the concepts of development, test, production, thus I searched the articles about this concepts.
As a result, I have learned that it is recommended to set either NODE_ENV to development or production (or test).
My issue starts from here.
First, I used to use .env file only, with variables set inside that file (Before using sequelize migration, I had no experience using config folder. I used .env file only.)
since this was my first time using config.js file, I could not distinguish the role between .env file and config file.
So, while reading,
How to store Node.js deployment settings/configuration files?
I saw that process.env.something (to use variables set in .env file) being used inside the config file.
below is the code,
//config.js
config.twitter.user_name = process.env.TWITTER_USER || 'username';
config.twitter.password= process.env.TWITTER_PASSWORD || 'password';
So the first question is that the .env file only set some secret variables, and config file uses that .env file(with process.env.) thus ultimately all the settings of my express application is inside of config file?
I am confused with the structure that seperates config file, and .env file.
I also read the article
https://goenning.net/2016/05/13/how-i-manage-application-configuration-with-nodejs/
according to that article,
there are development.js, production.js, test.js files inside of config folder.
but as I mentioned above, config.json file created from the command "sequelize init", has a key-value pair. (development, test, production).
vice versa, the article just above shows that config folder has files each for development, test, production.
So my second question is that, do I have to delete that config.json file which was created from "sequelize init" command, and integrate them to each files? (there may be no 100% correct-answer, but I want to know the most-widely-used and efficient way)
From now on, I even do not know how to setup the NODE_ENV, but I will keep searching for it.
Thanks for reading this long question, and it would be really appreciated to give me some advice on this issue.