mounting the API would be a good start...

This commit is contained in:
zkldi
2021-06-16 20:12:21 +01:00
parent 2207fb6a8e
commit fdd4945369
7 changed files with 26 additions and 1 deletions
@@ -2,12 +2,14 @@ import { Router } from "express";
import authRouter from "./auth/router";
import importRouter from "./import/router";
import statusRouter from "./status/router";
import usersRouter from "./users/router";
const router: Router = Router({ mergeParams: true });
router.use("/auth", authRouter);
router.use("/status", statusRouter);
router.use("/import", importRouter);
router.use("/users", usersRouter);
router.all("*", (req, res) =>
res.status(404).json({
@@ -0,0 +1,20 @@
import t from "tap";
import { CloseAllConnections } from "../../../../../../../../../test-utils/close-connections";
import mockApi from "../../../../../../../../../test-utils/mock-api";
import ResetDBState from "../../../../../../../../../test-utils/resets";
t.test("GET /api/v1/users/:userID/games/:game/:playtype/", (t) => {
t.beforeEach(ResetDBState);
t.test("Should return a users statistics for that game.", async (t) => {
const res = await mockApi.get("/api/v1/users/zkldi/games/iidx/SP");
t.strictSame(res.body, {});
t.end();
});
t.end();
});
t.teardown(CloseAllConnections);
@@ -2,6 +2,7 @@ import { Router } from "express";
import db from "../../../../../../external/mongo/db";
import { SYMBOL_TachiData } from "../../../../../../lib/constants/tachi";
import { GetUserFromParam } from "./middleware";
import gamePTRouter from "./games/_game/_playtype/router";
const router: Router = Router({ mergeParams: true });
@@ -40,4 +41,6 @@ router.get("/stats", async (req, res) => {
});
});
router.use("/games/:game/:playtype", gamePTRouter);
export default router;
@@ -1,6 +1,6 @@
import { Router } from "express";
import db from "../../../../../external/mongo/db";
import userIDRouter from "./!userID/router";
import userIDRouter from "./_userID/router";
const router: Router = Router({ mergeParams: true });