-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
43 lines (41 loc) · 1.42 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
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const expressJwt = require('express-jwt')
const swaggerUi = require('swagger-ui-express')
const YAML = require('yamljs')
const swaggerDocument = YAML.load('./swagger.yaml')
const cors = require('cors')
const keys = require('./config/keys')
require('./models/dbConnection')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cors())
app.use(
expressJwt({ secret: keys.secretKey }).unless({
path: [
/\/item*/,
/\/images*/,
/\/avatars*/,
'/user/sign_in',
'/user/sign_up',
'/order/get_all_orders',
/\/order\/get_user_orders*/,
/\/order\/get_item_orders*/,
/\/order\/get_order*/,
/\/order\/get_ask_price*/,
/\/order\/get_bid_price*/,
/\/api-docs*/
]
})
)
app.use('/', require('./routes'))
app.use('/item', require('./routes/itemRoutes'))
app.use('/user', require('./routes/userRoutes'))
app.use('/admin', require('./routes/adminRoutes'))
app.use('/order', require('./routes/orderRoutes'))
app.use('/match', require('./routes/matchRoutes'))
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
app.use(express.static('public'))
const PORT = process.env.PORT || 5000
app.listen(PORT, () => console.log(`server started at port ${PORT}.`))