aboutsummaryrefslogtreecommitdiffstats
path: root/backend/src/config
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswa Kalyan Bhuyan <[email protected]> 2025-04-29 10:47:43 +0530
committerLibravatarLibravatar Biswa Kalyan Bhuyan <[email protected]> 2025-04-29 10:47:43 +0530
commita2e0a65b2599267efe94d665d6305f59b225bbd5 (patch)
treee2cef2031e3f7655e0c5f419020a3f1064c3b7b8 /backend/src/config
parent570bf0f3f065d583d6f94ecfc61aae93ba3e43de (diff)
downloadrestaurant-a2e0a65b2599267efe94d665d6305f59b225bbd5.tar.gz
restaurant-a2e0a65b2599267efe94d665d6305f59b225bbd5.tar.bz2
restaurant-a2e0a65b2599267efe94d665d6305f59b225bbd5.zip
feat: added initlaized the frontend and backendHEADmaster
Diffstat (limited to 'backend/src/config')
-rw-r--r--backend/src/config/database.js14
-rw-r--r--backend/src/config/env.js11
-rw-r--r--backend/src/config/logger.js7
3 files changed, 32 insertions, 0 deletions
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
diff --git a/backend/src/config/env.js b/backend/src/config/env.js
new file mode 100644
index 0000000..9353571
--- /dev/null
+++ b/backend/src/config/env.js
@@ -0,0 +1,11 @@
+require('dotenv').config();
+
+const env = {
+ PORT: process.env.PORT || 5000,
+ MONGODB_URI: process.env.MONGODB_URI || 'mongodb://localhost:27017/restaurant',
+ JWT_SECRET: process.env.JWT_SECRET || 'your_jwt_secret_here',
+ NODE_ENV: process.env.NODE_ENV || 'development',
+ JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN || '30d'
+};
+
+module.exports = env; \ No newline at end of file
diff --git a/backend/src/config/logger.js b/backend/src/config/logger.js
new file mode 100644
index 0000000..c9897b0
--- /dev/null
+++ b/backend/src/config/logger.js
@@ -0,0 +1,7 @@
+const morgan = require('morgan');
+const env = require('./env');
+
+// Configure morgan logger
+const logger = morgan(env.NODE_ENV === 'development' ? 'dev' : 'combined');
+
+module.exports = logger; \ No newline at end of file