Express and Mongoose

To initialize the database connection, we are pulling in the MONGODB_URI that we have defined inside the .env file. We are feeding this to mongoose.connect() to initialize the database connection. Once MongoDB has been connected, we execute setRoutes() to initialize the routes and dispatch a static message if any reaches http://localhost:3000/ directly during development.

Get Google Cloud AI Services Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.