Initial commit
This commit is contained in:
15
server/config/db.js
Normal file
15
server/config/db.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
const connectDB = async () => {
|
||||
try {
|
||||
const conn = await mongoose.connect(process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/guitar_ecommerce');
|
||||
console.log(`[MongoDB Connected]: ${conn.connection.host}`);
|
||||
} catch (error) {
|
||||
console.error(`[MongoDB Connection Error]: ${error.message}`);
|
||||
// Process can continue for seed script or fallback handling
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = connectDB;
|
||||
|
||||
Reference in New Issue
Block a user