-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (33 loc) · 1.18 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// server.js
const express = require('express');
const dotenv = require('dotenv');
const mongoose = require('mongoose');
const dbURI = 'mongodb://localhost:27017/self-serving';
mongoose.connect('mongodb://localhost:27017/self-serving', {});
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
db.once('open', () => {
console.log('Connected to the database');
});
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
// Middleware
app.use(express.json());
// Routes
const cartRoutes = require('./routes/cartRoutes');
const menuItemRoutes = require('./routes/menuItemRoutes');
const adminRoutes = require('./routes/adminRoutes');
const customerRoutes = require('./routes/customerRoutes');
const orderRoutes = require('./routes/orderRoutes');
const chefRoutes = require('./routes/chefRoutes');
app.use('/api/cart', cartRoutes);
app.use('/api/menu', menuItemRoutes);
app.use('/api/admin', adminRoutes);
app.use('/api/customer', customerRoutes);
app.use('/api/order', orderRoutes);
app.use('/api/chef', chefRoutes);
// Start server
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});