mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
wip: migrating game handler
This commit is contained in:
1 parent
61d1871e95
commit
6043226142
26 files changed
+85
-364
No files matched your search
@@ -1,10 +1,11 @@
|
||||
import { Command, Quest, Session } from '@linux-odyssey/models'
|
||||
import { Command, Session } from '@linux-odyssey/models'
|
||||
import { matchedData } from 'express-validator'
|
||||
import type { Request, Response } from 'express'
|
||||
import CommandHandler from '../../game/commandHandler.js'
|
||||
import { pushToSession } from '../socket.js'
|
||||
import { finishSession } from '../../models/sessionManager.js'
|
||||
import { asyncHandler } from '../../middleware/error.js'
|
||||
import { questManager } from '../../models/quest.js'
|
||||
|
||||
export const newCommand = asyncHandler(async (req: Request, res: Response) => {
|
||||
const { command, pwd, output, error, params } = matchedData(req)
|
||||
@@ -37,7 +38,7 @@ export const newCommand = asyncHandler(async (req: Request, res: Response) => {
|
||||
|
||||
await c.save()
|
||||
|
||||
const quest = await Quest.findById(session.quest)
|
||||
const quest = await questManager.get(session.quest)
|
||||
if (!quest) {
|
||||
res.status(404).json({ message: 'quest not found' })
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user