Implemented MongoDB example db, updated documentation

This commit is contained in:
Alex Holliday committed 2024-05-13 14:21:27 -07:00
1 parent 8d6529d497
commit 8cc92e6c40
6 files changed
+154 -30

No files matched your search

+13 -16
View File
@@ -1,18 +1,15 @@
const mongoose = require('mongoose')
const PORT = process.env.PORT || 5000;
const PORT = process.env.PORT || 5000
const connectDbAndRunServer = async (app, db) => {
try {
await db.connect();
app.listen(PORT, () => {
console.log(`server started on port:${PORT}`);
});
} catch (error) {
console.log("Failed to connect to DB");
console.error(error);
}
};
const connectDbAndRunServer = async (app) => {
await mongoose.connect(process.env.DB_CONNECTION_STRING).then(() => {
console.log("DB connected")
// run server
app.listen(PORT, () => {
console.log(`server started on port:${PORT}`)
})
}).catch((err) => {
console.log(err)
})
}
module.exports = { connectDbAndRunServer }
module.exports = { connectDbAndRunServer };