I have server.js and db.js The db.js file interacts with my database using Mongoose and I use server.js to call functions
server.js
db.js
If you are using MongoDB Atlas. You need to Whitelist your IP address on the Atlas Console in the security settings.