-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (27 loc) · 973 Bytes
/
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
const express = require('express')
const app = express()
const swaggerUi = require('swagger-ui-express')
const yaml = require('yamljs')
// const fileUpload = require('express-fileupload')
const file = require('./api/controllers/file.js')
const publicDir = `${__dirname}/public`
const swaggerdoc = yaml.load(`${publicDir}/swaggerdoc.yaml`)
const port = process.env.PORT || 3000
app.set('port', port)
app.use(express.static(publicDir))
app.use('/doc', swaggerUi.serve, swaggerUi.setup(swaggerdoc, {}))
// app.use(fileUpload())
// Routing
// GET /files
app.get('/files', file.resumeFiles)
// GET /files/{file_id}/infos
app.get('/files/:file_id/infos', file.getInfoFile)
// /files/{file_id}
app.get('/files/:file_id', file.downloadFile)
// POST /files/post
//app.post('/files/post', file.uploadFile)
// Listen for requests
const server = app.listen(app.get('port'), function() {
const port = server.address().port
console.log('Magic happens on port ' + port)
})