-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (32 loc) · 1.07 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
const express = require('express')
const app = express()
require('dotenv').config()
require('./db/connection')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const testRoute = require('./routes/testRoute')
const categoryRoute = require('./routes/categoryRoute')
const productRoute = require('./routes/productRoute')
const userRoute = require('./routes/userRoute')
const orderRoute = require('./routes/orderRoute')
const paymentRoute = require('./routes/paymentRoute')
// app.get('/',(req,res)=>{
// res.send('Welcome to node js')
// })
// middleware
app.use(morgan('dev'))
app.use(bodyParser.json())
app.use('/public/uploads',express.static('public/uploads'))
app.use(cors())
// routes middleware - check if we can let the req proceed forward or not
app.use('/api',testRoute)
app.use('/api',categoryRoute)
app.use('/api',productRoute)
app.use('/api',userRoute)
app.use('/api',orderRoute)
app.use('/api',paymentRoute)
const port = process.env.PORT || 5000
app.listen(port,()=>{
console.log(`server started on port ${port}`)
})