From a2e0a65b2599267efe94d665d6305f59b225bbd5 Mon Sep 17 00:00:00 2001 From: Biswa Kalyan Bhuyan Date: Tue, 29 Apr 2025 10:47:43 +0530 Subject: feat: added initlaized the frontend and backend --- backend/src/config/database.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 backend/src/config/database.js (limited to 'backend/src/config/database.js') diff --git a/backend/src/config/database.js b/backend/src/config/database.js new file mode 100644 index 0000000..8fd758e --- /dev/null +++ b/backend/src/config/database.js @@ -0,0 +1,14 @@ +const mongoose = require('mongoose'); + +const connectDB = async () => { + try { + const conn = await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/restaurant'); + console.log(`MongoDB Connected: ${conn.connection.host}`); + return conn; + } catch (error) { + console.error(`Error: ${error.message}`); + process.exit(1); + } +}; + +module.exports = connectDB; \ No newline at end of file -- cgit v1.2.3-59-g8ed1b