final changes
This commit is contained in:
16
backend/config/db.js
Normal file
16
backend/config/db.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const connectDB = async () => {
|
||||
try {
|
||||
await mongoose.connect(process.env.MONGODB_URI, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
});
|
||||
console.log("MongoDB connected");
|
||||
} catch (err) {
|
||||
console.error("MongoDB connection error:", err);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = connectDB;
|
||||
Reference in New Issue
Block a user