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
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Setting up a hosted MongoDB server4m 22s
-
(Locked)
Connecting to MongoDB3m 27s
-
(Locked)
Adding MongoDB and Mongoose to an Express project4m 54s
-
(Locked)
Creating a user schema for Mongoose6m 21s
-
(Locked)
Using bcrypt to hash and validate passwords1m 31s
-
(Locked)
Adding password encryption and validation to a Mongoose model5m 12s
-
(Locked)
Creating a user registration route5m 36s
-
(Locked)
Testing the form and reviewing the data in MongoDB1m 33s
-
(Locked)
-
-
-
-