Skip to content

Commit

Permalink
move db out of server file
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-flynn committed Jul 21, 2023
1 parent c9c8e7b commit 7bf9ff3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const mongoose = require('mongoose');

//mongodb connection
const dbOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
const mongoConnect = async () => {
try {
await mongoose.connect(process.env.MONGO_URI, dbOptions);
console.log('Success connecting to mongodb');
} catch (error) {
console.log('error connecting to mongodb');
}
};
mongoConnect();

0 comments on commit 7bf9ff3

Please sign in to comment.