feat(api): add auth middleware to protect game endpoints
- Add requireAuth middleware using Better Auth session validation - Apply to all game routes (start, answer) - Unauthenticated requests return 401
This commit is contained in:
parent
91a3112d8b
commit
a3685a9e68
13 changed files with 196 additions and 24 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import express from "express";
|
||||
import type { Router } from "express";
|
||||
import { createGame, submitAnswer } from "../controllers/gameController.js";
|
||||
import { requireAuth } from "../middleware/authMiddleware.js";
|
||||
|
||||
export const gameRouter: Router = express.Router();
|
||||
|
||||
gameRouter.use(requireAuth);
|
||||
gameRouter.post("/start", createGame);
|
||||
gameRouter.post("/answer", submitAnswer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue