-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
37 lines (28 loc) · 835 Bytes
/
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
const express = require('express')
const cookieParser = require('cookie-parser')
const morgan = require('morgan')
const fileUpload = require('express-fileupload')
const app = express()
const path = require('path')
require('dotenv').config()
require('./config/connectDb.config')
const productRouter = require('./routes/product.route')
app.use(morgan('dev'))
app.use(cookieParser())
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(fileUpload({
createParentPath: true
}))
app.use('/api/product', productRouter)
app.use('/uploads', express.static(
path.join(__dirname, '/uploads')
))
app.listen(process.env.PORT || 5001, (error) => {
if (error) {
console.log(error.message)
} else {
console.log(`Listening on port ${process.env.PORT}`)
}
})
module.exports = app