Configuration information should be exposed on an API endpoint for the client.

Fixes #638
This commit is contained in:
zkldi
2022-01-29 16:37:42 +00:00
parent 501f87c784
commit cd07ca0c13
2 changed files with 36 additions and 2 deletions
@@ -1,7 +1,24 @@
import { ServerConfig } from "lib/setup/config";
import { ServerConfig, TachiConfig } from "lib/setup/config";
import t from "tap";
import mockApi from "test-utils/mock-api";
t.test("GET /api/v1/config", async (t) => {
const res = await mockApi.get("/api/v1/config");
t.strictSame(
res.body.body,
{
games: TachiConfig.GAMES,
importTypes: TachiConfig.IMPORT_TYPES,
name: TachiConfig.NAME,
type: TachiConfig.TYPE,
},
"Should return TachiConfig info"
);
t.end();
});
t.test("GET /api/v1/config/beatoraja-queue-size", async (t) => {
const res = await mockApi.get("/api/v1/config/beatoraja-queue-size");
@@ -1,9 +1,26 @@
import { Router } from "express";
import { ServerConfig } from "lib/setup/config";
import { ServerConfig, TachiConfig } from "lib/setup/config";
import { RequireBokutachi } from "server/middleware/type-require";
const router: Router = Router({ mergeParams: true });
/**
* Returns Tachi Configuration info, such as server name, type, supported games
* and more.
*/
router.get("/", (req, res) =>
res.status(200).json({
success: true,
description: `Returned configuration info.`,
body: {
games: TachiConfig.GAMES,
importTypes: TachiConfig.IMPORT_TYPES,
name: TachiConfig.NAME,
type: TachiConfig.TYPE,
},
})
);
/**
* Returns the value of the BEATORAJA_QUEUE_SIZE.
*