ShieldX's picture
Upload 13 files
c0fb352 verified
raw
history blame contribute delete
379 Bytes
// config/db.js
import mongoose from 'mongoose';
export const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGODB_URI);
console.log(`🤎 MongoDB Connected: ${conn.connection.host}`);
} catch (error) {
console.error(`❌ Error connecting to MongoDB: ${error.message}`);
process.exit(1); // Exit process with failure
}
};