Re-organize code

This commit is contained in:
wancat committed 2023-07-18 20:33:08 +08:00
1 parent 8901b385ad
commit d51a75e5bc
7 files changed
+7 -5

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
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 './api/socket.js'
const port = 3000
const app = express()
const server = http.createServer(app)
socketServer(server)
const file = fs.readFileSync('./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!')
})
server.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`)
})