mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
Add swagger
This commit is contained in:
1 parent
20f64e1426
commit
8901b385ad
4 files changed
+486
-2
No files matched your search
@@ -1,5 +1,9 @@
|
||||
import fs from 'fs'
|
||||
import express from 'express'
|
||||
import http from 'http'
|
||||
import YAML from 'yaml'
|
||||
import swaggerUI from 'swagger-ui-express'
|
||||
|
||||
import socketServer from './socket.js'
|
||||
|
||||
const port = 3000
|
||||
@@ -7,6 +11,10 @@ const app = express()
|
||||
const server = http.createServer(app)
|
||||
socketServer(server)
|
||||
|
||||
const file = fs.readFileSync('./api/swagger.yaml', 'utf8')
|
||||
const swaggerDocument = YAML.parse(file)
|
||||
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument))
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!')
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user