forked from ALPHACamp/twitter-api-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (19 loc) · 759 Bytes
/
app.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
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const app = express()
const port = process.env.PORT || 3000
app.use(express.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use('/upload', express.static(__dirname + '/upload'))
app.use(cors())
const swaggerUi = require('swagger-ui-express')
const swaggerDocument = require('./config/swagger.json')
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
app.get('/', (req, res) => res.send('請使用API接口'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
require('./routes')(app)
module.exports = app