mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-30 02:48:01 +03:00
Configuration information should be exposed on an API endpoint for the client.
Fixes #638
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user