From the course: Advanced Express

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Connecting to MongoDB

Connecting to MongoDB

From the course: Advanced Express

Start my 1-month free trial

Connecting to MongoDB

- [Narrator] How do we provide the previously created credentials to our application? We need a way to work with different databases depending on the environment. Luckily, our configuration does already support that so if we look into server config index js, we see here on line six that we have a property development. On line 17 we have a property production and if we scroll down, on line 28, we have a property test. On the other hand, we should not store credentials with our application code, especially if this is committed to some version control system like ki-tar. That's why I installed a module called dotenv already, to see that I'm requiring it up here on line one, and what dotenv does is it looks for fouls with the name dotenv in our project route and brings the setting in then as environment variables on process and you can see that here, for example, on line 14, we bring in process.env.DEVELOPMENT_DB_DSN. So set these variables to sample project or ID contains a file dotenv…

Contents