-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
57 lines (37 loc) · 1.31 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const connectToMongo = require('./config');
const bodyParser = require('body-parser')
const express = require('express')
const cors = require('cors')
const path = require('path');
const auth = require('./routes/auth');
const cart = require('./routes/cart')
const wishlist = require('./routes/wishlist')
const product = require('./routes/product')
const review = require('./routes/review')
const paymentRoute = require('./routes/paymentRoute')
const forgotPassword = require('./routes/forgotPassword')
const AdminRoute = require('./routes/Admin/AdminAuth')
const dotenv = require('dotenv');
const checkOrigin = require('./middleware/apiAuth');
dotenv.config()
connectToMongo();
const port = 5000
const app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.use(cors());
app.use(express.static(path.join(__dirname, 'build')));
app.use(checkOrigin);
app.use('/api/auth', auth)
app.use('/api/product', product)
app.use('/api/cart', cart)
app.use('/api/wishlist', wishlist)
app.use('/api/review', review)
app.use('/api/admin', AdminRoute)
app.use('/api', paymentRoute)
app.use('/api/password', forgotPassword)
app.listen(port, () => {
console.log(`E-commerce backend listening at http://localhost:${port}`)
})