-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (31 loc) · 1.01 KB
/
app.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
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
// Import routes
const authRoutes = require('./routes/authRoutes');
const orderRoutes = require('./routes/orderRoutes');
// const customerRoutes = require('./routes/customerRoutes');
// const reportRoutes = require('./routes/reportRoutes');
// const contactRoutes = require('./routes/contactRoutes');
// Load environment variables
dotenv.config();
const app = express();
// Middleware
app.use(cors());
app.use(bodyParser.json());
// API Routes
app.use('/api/auth', authRoutes);
app.use('/api/orders', orderRoutes);
// app.use('/api/customers', customerRoutes);
// app.use('/api/reports', reportRoutes);
// app.use('/api/contact', contactRoutes);
// Test
app.use('/', (req, res) => {
res.send('<h1>Hello World</h1>')
})
// Error handling middleware (for uncaught routes)
app.use((req, res) => {
res.status(404).json({ message: 'Route not found' });
});
module.exports = app;