Skip to content

Commit 6299af0

Browse files
committed
added db config
1 parent 5b9c0a0 commit 6299af0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

backend/config/db.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import mongoose from 'mongoose';
2+
3+
export const connectDB = async () => {
4+
try {
5+
const conn = await mongoose.connect(process.env.MONGO_URI);
6+
console.log(`MongoDB Connected: ${conn.connection.host}`);
7+
} catch (error) {
8+
console.error(`Error: ${error.message}`);
9+
process.exit(1);
10+
}
11+
}

0 commit comments

Comments
 (0)