-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
35 lines (28 loc) · 1003 Bytes
/
index.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
const express = require('express');
const dotenv = require('dotenv');
const helmet = require('helmet');
const cors = require('cors');
const authRoutes = require('./src/routes/authRoutes');
const orderRoutes = require('./src/routes/orderRoutes');
const menuRoutes = require('./src/routes/menuRoutes');
const profileRoutes = require('./src/routes/profileRoutes');
const transactionRoutes = require('./src/routes/transactionRoutes');
dotenv.config();
const app = express();
app.use(helmet());
app.use(cors());
app.use(express.json());
app.use('/api/vendor', authRoutes);
app.use('/api/vendor/orders', orderRoutes);
app.use('/api/vendor', menuRoutes);
app.use('/api/vendor', profileRoutes);
app.use('/api/vendor', transactionRoutes);
// Error handling middleware
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send('Something broke!');
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});