-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
59 lines (41 loc) · 1.61 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
47
48
49
50
51
52
53
54
55
56
57
58
59
const express = require('express');
const connectDB = require('./config/db');
// const cors = require('cors');
const cors = require('dotenv');
const ejs = require('ejs');
const bodyParser = require('body-parser');
const app = express();
// Middleware
// app.use(cors());
app.use(express.json());
app.use(bodyParser.json());
app.set('view engine', 'html');
app.engine('html', ejs.renderFile)
app.use(express.static('./public'))
// Connect to MongoDB
connectDB();
// Import routes
const categoryRoutes = require('./routes/category');
app.use('/api/categories', categoryRoutes);
const EmailyRoutes = require('./routes/email');
app.use('/api/send', EmailyRoutes);
const itemRoutes = require('./routes/item');
app.use('/api/item', itemRoutes);
const LoginRoutes = require('./routes/user');
app.use('/api/register', LoginRoutes);
const vendorRoutes = require('./routes/vendor');
app.use('/api/vendor', vendorRoutes);
const purchaseRoutes = require('./routes/purchase');
app.use('/api/purchase', purchaseRoutes);
const purchaseReciveRoutes = require('./routes/recive');
app.use('/api/recive', purchaseReciveRoutes);
const PaymentRoutes = require('./routes/payment');
app.use('/api/payment', PaymentRoutes);
const OrderRoutes = require('./routes/order');
app.use('/api/order', OrderRoutes);
const CustomerRoutes = require('./routes/customer');
app.use('/api/customer', CustomerRoutes);
const UserRoutes = require('./routes/user');
app.use('/api/user', UserRoutes);
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server running on port ${ PORT }`));