import express from "express";
import type { Router } from "express";
import { createGameController } from "../controllers/gameController.js";
import { requireAuth } from "../middleware/authMiddleware.js";
import { gameLimiter } from "../middleware/rateLimiters.js";
import type { GameSessionStore } from "../gameSessionStore/index.js";

export const createGameRouter = (store: GameSessionStore): Router => {
  const router = express.Router();
  const controller = createGameController(store);

  router.use(requireAuth);
  router.use(gameLimiter);

  router.post("/start", controller.createGame as express.RequestHandler);
  router.post("/answer", controller.submitAnswer as express.RequestHandler);
  
  return router;
};
