refactor: dependency injection for GameSessionStore via composition root
This commit is contained in:
parent
4f59f3bc14
commit
a4a4bfff57
6 changed files with 107 additions and 79 deletions
|
|
@ -1,11 +1,16 @@
|
|||
import express from "express";
|
||||
import { Router } from "express";
|
||||
import type { Router } from "express";
|
||||
import { healthRouter } from "./healthRouter.js";
|
||||
import { gameRouter } from "./gameRouter.js";
|
||||
import { createGameRouter } from "./gameRouter.js";
|
||||
import { lobbyRouter } from "./lobbyRouter.js";
|
||||
import type { GameSessionStore } from "../gameSessionStore/index.js";
|
||||
|
||||
export const apiRouter: Router = express.Router();
|
||||
export const createApiRouter = (store: GameSessionStore): Router => {
|
||||
const router = express.Router();
|
||||
|
||||
apiRouter.use("/health", healthRouter);
|
||||
apiRouter.use("/game", gameRouter);
|
||||
apiRouter.use("/lobbies", lobbyRouter);
|
||||
router.use("/health", healthRouter);
|
||||
router.use("/game", createGameRouter(store));
|
||||
router.use("/lobbies", lobbyRouter);
|
||||
|
||||
return router;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue