init commit
This commit is contained in:
13
backend/config/db.js
Normal file
13
backend/config/db.js
Normal file
@ -0,0 +1,13 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const connectDB = async () => {
|
||||
try {
|
||||
await mongoose.connect(process.env.MONGO_URI, {});
|
||||
console.log("MongoDB connected");
|
||||
} catch (err) {
|
||||
console.error("Error connecting to MongoDB", err);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = connectDB;
|
||||
Reference in New Issue
Block a user