-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
66 lines (51 loc) · 2.11 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
60
61
62
63
64
65
66
require('dotenv').config();
const express = require('express');
const materialRoutes = require('./src/routes/material.routes');
const projectRoutes = require('./src/routes/project.routes')
const houseplanRoutes = require('./src/routes/houseplan.routes')
const ordersRoutes = require('./src/routes/orders.routes')
const paymentRoutes = require('./src/routes/payment.routes')
const bidRoutes = require('./src/routes/bid.routes')
const usersRoutes = require('./src/routes/auth.routes')
const bodyParser = require('body-parser');
const cors = require('cors')
const cookieParser = require('cookie-parser')
const corsOptions = require('../server/config/corsOptions')
const refreshRoutes = require('./src/routes/refresh.route')
const logOutRoute = require('./src/routes/logOut.route')
const verifyJwt = require('./src/middleware/verifyJWT')
const supplierDashboardRoute = require('./src/routes/supplierDashboard.route')
// Creating an express app
const app = express();
const port = process.env.PORT || 4000;
// Parse request of Content-type -application/x-www-form-urlencoded
// app.use(bodyParser.urlencoded({ extended: true }));
// Parse request of content-type - application/json
// app.use(bodyParser.json());
app.use(cors())
app.use(express.json());
// app.use(express.urlencoded({ extended: true }));
app.use(express.urlencoded({extended:false}))
//middleware of cookies
app.use(cookieParser())
// Define a root route
app.get('/', (req, res) => {
res.send('Hello World!');
// req.
});
// Using employeeRoutes as middleware
app.use('/api/user', usersRoutes )
app.use('/api/v1/refresh', refreshRoutes )
app.use('/api/v1/logout', logOutRoute)
app.use(verifyJwt)
app.use('/api/supplier/dashboard', supplierDashboardRoute)
app.use('/api/v1/material', materialRoutes);
app.use('/api/v1/project', projectRoutes )
app.use('/api/v1/bid', bidRoutes )
app.use('/api/v1/orders', ordersRoutes )
app.use('/api/v1/payment', paymentRoutes )
app.use('/api/v1/houseplan', houseplanRoutes )
// Listen to requests
app.listen(port, () => {
console.log(`Server is listening on Port ${port}`);
});