UNPKG

poem_game_component

Version:

32 lines (22 loc) 1.16 kB
import { Router } from 'express'; import { GameController } from '../controllers/GameController'; export function createGameRoutes(gameController: GameController): Router { const router = Router(); // 创建游戏 router.post('/', (req, res) => gameController.createGame(req, res)); // 获取未开始的游戏列表 router.get('/preparing', (req, res) => gameController.getPreparingGames(req, res)); // 获取未结束的游戏列表 router.get('/not-finished', (req, res) => gameController.getNotFinishedGames(req, res)); // 获取已结束的游戏列表 router.get('/finished', (req, res) => gameController.getFinishedGames(req, res)); // 获取特定游戏 router.get('/:gameId', (req, res) => gameController.getGame(req, res)); // 加入游戏 router.post('/:gameId/join', (req, res) => gameController.joinGame(req, res)); // 开始游戏 router.post('/:gameId/start', (req, res) => gameController.startGame(req, res)); // 提交答案 router.post('/:gameId/answer', (req, res) => gameController.submitAnswer(req, res)); return router; }