Define routes, controllers of sessions

Work in progress, debugging
This commit is contained in:
wancat committed 2023-07-19 16:42:09 +08:00
1 parent 50443b96e0
commit 04edfdd0dc
13 files changed
+1835 -60

No files matched your search

+22 -15
View File
@@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'fs/promises'
import express from 'express'
import http from 'http'
import YAML from 'yaml'
@@ -6,21 +6,28 @@ import swaggerUI from 'swagger-ui-express'
import socketServer from './api/socket.js'
import connectDB from './db.js'
import apiRouter from './api/routes/index.js'
const port = 3000
const app = express()
const server = http.createServer(app)
socketServer(server)
connectDB()
async function main() {
const port = 3000
const app = express()
const server = http.createServer(app)
socketServer(server)
await connectDB()
const file = fs.readFileSync('./swagger.yaml', 'utf8')
const swaggerDocument = YAML.parse(file)
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument))
const file = await fs.readFile('./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!')
})
app.get('/', (req, res) => {
res.send('Hello World!')
})
server.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`)
})
app.use('/api/v1', apiRouter)
server.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`)
})
}
main().catch((err) => console.log(err))