wip: migrating game handler

This commit is contained in:
Justin Lin committed 2025-04-18 14:27:36 +08:00
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