From 8db352f48e750913f6a0249be30052d1308ec509 Mon Sep 17 00:00:00 2001 From: zkldi Date: Fri, 5 Nov 2021 04:51:05 +0000 Subject: [PATCH] Refactor config to use TachiConfig for metainfo --- server/package.json | 2 +- server/pnpm-lock.yaml | 8 ++-- .../scripts/single-use/add-tierlist-info.ts | 4 +- server/scripts/sync-database/sync-database.ts | 10 ++--- server/src/external/mongo/indexes.ts | 4 +- server/src/external/mongo/schemas.ts | 4 +- server/src/external/redis/redis-IPC.ts | 4 +- server/src/lib/constants/ea3id.ts | 2 + server/src/lib/email/formats.ts | 4 +- .../common/api-kai/traverse-api.ts | 6 +-- .../common/batch-manual/parser.ts | 10 ++--- .../score-import/import-types/common/types.ts | 3 ++ .../score-import/import-types/converters.ts | 2 + .../import-types/ir/beatoraja/converter.ts | 6 +-- server/src/lib/search/search.ts | 4 +- server/src/lib/setup/config.ts | 40 ++++++++++--------- server/src/main.ts | 4 +- server/src/server/middleware/rate-limiter.ts | 4 +- server/src/server/middleware/type-require.ts | 6 +-- .../src/server/router/api/v1/admin/router.ts | 4 +- .../src/server/router/api/v1/auth/router.ts | 2 +- .../router/api/v1/games/_game/middleware.ts | 4 +- .../server/router/api/v1/games/router.test.ts | 6 +-- .../src/server/router/api/v1/games/router.ts | 10 ++--- .../src/server/router/api/v1/import/router.ts | 6 +-- server/src/server/server.ts | 6 +-- server/src/utils/misc.ts | 4 +- 27 files changed, 86 insertions(+), 83 deletions(-) diff --git a/server/package.json b/server/package.json index dfea4ad47..9fb46e008 100644 --- a/server/package.json +++ b/server/package.json @@ -79,7 +79,7 @@ "redis": "3.1.2", "rimraf": "3.0.2", "safe-json-stringify": "1.2.0", - "tachi-common": "0.2.36", + "tachi-common": "0.2.38", "ts-node": "10.0.0", "typescript": "4.3.4", "winston": "3.3.3", diff --git a/server/pnpm-lock.yaml b/server/pnpm-lock.yaml index e50df4826..203a78259 100644 --- a/server/pnpm-lock.yaml +++ b/server/pnpm-lock.yaml @@ -61,7 +61,7 @@ specifiers: rimraf: 3.0.2 safe-json-stringify: 1.2.0 supertest: 6.1.3 - tachi-common: 0.2.36 + tachi-common: 0.2.38 tap: 15.0.9 ts-node: 10.0.0 tsconfig-paths: 3.10.1 @@ -104,7 +104,7 @@ dependencies: redis: 3.1.2 rimraf: 3.0.2 safe-json-stringify: 1.2.0 - tachi-common: 0.2.36 + tachi-common: 0.2.38 ts-node: 10.0.0_83f53b0a0c5616d3fa00ed4e30b9ce1b typescript: 4.3.4 winston: 3.3.3 @@ -4260,8 +4260,8 @@ packages: strip-ansi: 6.0.0 dev: true - /tachi-common/0.2.36: - resolution: {integrity: sha512-4/enfkwE8HA4x4vrbNMrhLx2j/8JGnEMwAO5b0zSM150chDZiK30vXOmDW1IHSqxoIRZVuIyRqP7aEyUbf7FKA==} + /tachi-common/0.2.38: + resolution: {integrity: sha512-hsiutwz/TKjYRcV6TsFDhpPHUalKDF2IVJGX5K9UuAAynU2K/wJ5qHG3xWH4pEjYz0B0Vx263HGY2johCEDAAA==} dependencies: monk: 7.3.4 transitivePeerDependencies: diff --git a/server/scripts/single-use/add-tierlist-info.ts b/server/scripts/single-use/add-tierlist-info.ts index 25dd2b1d2..2c512a0fc 100644 --- a/server/scripts/single-use/add-tierlist-info.ts +++ b/server/scripts/single-use/add-tierlist-info.ts @@ -1,12 +1,12 @@ import db from "external/mongo/db"; import CreateLogCtx from "lib/logger/logger"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; const logger = CreateLogCtx(__filename); if (require.main === module) { (async () => { - for (const game of ServerTypeInfo.supportedGames) { + for (const game of TachiConfig.GAMES) { // eslint-disable-next-line no-await-in-loop const res = await db.charts[game].update( { tierlistInfo: { $exists: false } }, diff --git a/server/scripts/sync-database/sync-database.ts b/server/scripts/sync-database/sync-database.ts index c83e46d68..4e621dc13 100644 --- a/server/scripts/sync-database/sync-database.ts +++ b/server/scripts/sync-database/sync-database.ts @@ -6,7 +6,7 @@ import deepEqual from "deep-equal"; import { monkDB } from "external/mongo/db"; import fs from "fs"; import CreateLogCtx, { KtLogger } from "lib/logger/logger"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { BulkWriteOperation } from "mongodb"; import { ICollection } from "monk"; import os from "os"; @@ -119,7 +119,7 @@ const syncInstructions: SyncInstructions[] = [ const bwriteOps: BulkWriteOperation[] = []; for (const folder of folders) { - if (!ServerTypeInfo.supportedGames.includes(folder.game)) { + if (!TachiConfig.GAMES.includes(folder.game)) { continue; // Skip things for games we don't care about. } @@ -162,7 +162,7 @@ const syncInstructions: SyncInstructions[] = [ const bwriteOps: BulkWriteOperation[] = []; for (const table of tables) { - if (!ServerTypeInfo.supportedGames.includes(table.game)) { + if (!TachiConfig.GAMES.includes(table.game)) { continue; // Skip things for games we don't care about. } @@ -218,9 +218,9 @@ async function SynchroniseDBWithSeeds() { if (collectionName.startsWith("songs-") || collectionName.startsWith("charts-")) { const game = collectionName.split("-")[1]; - if (!ServerTypeInfo.supportedGames.includes(game as any)) { + if (!TachiConfig.GAMES.includes(game as any)) { spawnLogger.info( - `Skipping ${collectionName} (${game}) as it isn't for ${ServerTypeInfo.name}.` + `Skipping ${collectionName} (${game}) as it isn't for ${TachiConfig.NAME}.` ); continue; } diff --git a/server/src/external/mongo/indexes.ts b/server/src/external/mongo/indexes.ts index 3e8c47ca9..32d0e7a25 100644 --- a/server/src/external/mongo/indexes.ts +++ b/server/src/external/mongo/indexes.ts @@ -2,7 +2,7 @@ import monk, { IMonkManager } from "monk"; import { IndexOptions } from "mongodb"; import CreateLogCtx from "lib/logger/logger"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { ONE_DAY } from "lib/constants/time"; import { Databases } from "./db"; @@ -87,7 +87,7 @@ const staticIndexes: Partial> = { const indexes: Partial> = staticIndexes; -for (const game of ServerTypeInfo.supportedGames) { +for (const game of TachiConfig.GAMES) { if (indexes[`charts-${game}` as Databases]) { indexes[`charts-${game}` as Databases]!.push( index({ chartID: 1 }, UNIQUE), diff --git a/server/src/external/mongo/schemas.ts b/server/src/external/mongo/schemas.ts index 564c873bf..305b0ccec 100644 --- a/server/src/external/mongo/schemas.ts +++ b/server/src/external/mongo/schemas.ts @@ -10,7 +10,7 @@ import { allIDStrings, allImportTypes } from "tachi-common/js/config/static-conf import p, { PrudenceSchema } from "prudence"; import { Databases } from "./db"; import { AllPermissions } from "server/middleware/auth"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { IsValidGame, IsValidPlaytype } from "utils/misc"; import { optNull } from "utils/prudence"; @@ -32,7 +32,7 @@ function prSchemaify(schema: PrudenceSchema) { }; } -const games = ServerTypeInfo.supportedGames; +const games = TachiConfig.GAMES; const isValidPlaytype = (self: unknown, parent: Record) => { if (!parent.game || typeof parent.game !== "string" || !IsValidGame(parent.game)) { throw new Error(`Invalid Schema, need game to base IsValidPlaytype off of.`); diff --git a/server/src/external/redis/redis-IPC.ts b/server/src/external/redis/redis-IPC.ts index d50d5eaf4..d74cbeb46 100644 --- a/server/src/external/redis/redis-IPC.ts +++ b/server/src/external/redis/redis-IPC.ts @@ -1,6 +1,6 @@ import redis from "redis"; import CreateLogCtx from "lib/logger/logger"; -import { ServerConfig } from "lib/setup/config"; +import { ServerConfig, TachiConfig } from "lib/setup/config"; /** * This code has been stubbed out! It doesn't really have a use at the moment. @@ -33,7 +33,7 @@ const SubCallbacks: Partial = {}; const SubClient = redis.createClient(); const PubClient = redis.createClient(); -const PREFIX = ServerConfig.TYPE.toUpperCase(); // KTCHI or BTCHI +const PREFIX = TachiConfig.NAME.toUpperCase(); export function RedisPub(channel: T, data: RedisIPCData[T]) { PubClient.publish(`${PREFIX}-${channel}`, JSON.stringify(data)); diff --git a/server/src/lib/constants/ea3id.ts b/server/src/lib/constants/ea3id.ts index d07e48a95..1977ec30f 100644 --- a/server/src/lib/constants/ea3id.ts +++ b/server/src/lib/constants/ea3id.ts @@ -8,3 +8,5 @@ export const REV_2DXBMS = "Z"; export const REV_OMNIMIX = "X"; export const EXT_HEROIC_VERSE = "2020092900"; + +export const MODEL_SDVX3_KONASTE = "QCV"; diff --git a/server/src/lib/email/formats.ts b/server/src/lib/email/formats.ts index 968ed657f..6847a7d80 100644 --- a/server/src/lib/email/formats.ts +++ b/server/src/lib/email/formats.ts @@ -1,7 +1,7 @@ // Email HTML is a hellish mess of IE5 era nonsense. // Good luck. -import { ServerConfig, ServerTypeInfo } from "lib/setup/config"; +import { ServerConfig, TachiConfig, TachiServerConfig } from "lib/setup/config"; export function EmailFormatResetPassword(username: string, resetCode: string, ipAddr: string) { return MainHTMLWrapper( @@ -23,7 +23,7 @@ export function MainHTMLWrapper(innerHTML: string) { - ${ServerTypeInfo.name} + ${TachiConfig.NAME} ${innerHTML} diff --git a/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts b/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts index 337e4891f..6e59616fd 100644 --- a/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts +++ b/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts @@ -2,7 +2,7 @@ import { KtLogger } from "lib/logger/logger"; import ScoreImportFatalError from "../../../framework/score-importing/score-import-error"; import nodeFetch from "utils/fetch"; import { VERSION_STR } from "lib/constants/version"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; /** * A Kai Reauth function is an async function that returns a string @@ -70,7 +70,7 @@ export async function* TraverseKaiAPI( res = await fetch(url, { headers: { Authorization: `Bearer ${token}`, - "User-Agent": `${ServerTypeInfo.name}/${VERSION_STR}`, + "User-Agent": `${TachiConfig.NAME}/${VERSION_STR}`, "Content-Type": "application/json", }, }); @@ -127,7 +127,7 @@ export async function* TraverseKaiAPI( throw new ScoreImportFatalError( 500, - `Recieved no _links prop from ${url}. This is not an error with ${ServerTypeInfo.name}.` + `Recieved no _links prop from ${url}. This is not an error with ${TachiConfig.NAME}.` ); } diff --git a/server/src/lib/score-import/import-types/common/batch-manual/parser.ts b/server/src/lib/score-import/import-types/common/batch-manual/parser.ts index c26631905..1d4c7906d 100644 --- a/server/src/lib/score-import/import-types/common/batch-manual/parser.ts +++ b/server/src/lib/score-import/import-types/common/batch-manual/parser.ts @@ -14,7 +14,7 @@ import { import deepmerge from "deepmerge"; import { FormatPrError } from "utils/prudence"; import { ParserFunctionReturns } from "../types"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; const optNull = (v: ValidSchemaValue) => p.optional(p.nullable(v)); @@ -172,7 +172,7 @@ const PR_BatchManualScore = (game: Game, playtype: Playtypes[Game]): PrudenceSch const PR_BatchManual = (game: Game, playtype: Playtypes[Game]): PrudenceSchema => ({ meta: { service: p.isBoundedString(3, 15), - game: p.isIn(ServerTypeInfo.supportedGames), + game: p.isIn(TachiConfig.GAMES), playtype: p.is(playtype), version: "*?string", }, @@ -222,12 +222,10 @@ export function ParseBatchManualFromObject( ); } - if (!ServerTypeInfo.supportedGames.includes(possiblyGame)) { + if (!TachiConfig.GAMES.includes(possiblyGame)) { throw new ScoreImportFatalError( 400, - `Invalid game ${possiblyGame} - expected any of ${ServerTypeInfo.supportedGames.join( - ", " - )}.` + `Invalid game ${possiblyGame} - expected any of ${TachiConfig.GAMES.join(", ")}.` ); } diff --git a/server/src/lib/score-import/import-types/common/types.ts b/server/src/lib/score-import/import-types/common/types.ts index 219221f72..32aed2650 100644 --- a/server/src/lib/score-import/import-types/common/types.ts +++ b/server/src/lib/score-import/import-types/common/types.ts @@ -23,6 +23,7 @@ import { BeatorajaContext, BeatorajaScore } from "../ir/beatoraja/types"; import { USCClientScore } from "server/router/ir/usc/types"; import { IRUSCContext } from "../ir/usc/types"; import { ClassHandler } from "../../framework/user-game-stats/types"; +import { KsHookSV3CScore } from "../ir/kshook-sv3c/types"; export interface ImportTypeDataMap { "file/eamusement-iidx-csv": IIDXEamusementCSVData; "file/batch-manual": BatchManualScore; @@ -37,6 +38,7 @@ export interface ImportTypeDataMap { "ir/chunitachi": BatchManualScore; "ir/beatoraja": BeatorajaScore; "ir/usc": USCClientScore; + "ir/kshook-sv3c": KsHookSV3CScore; // These aren't placeholder values - the data is yielded in a way that // the value of these is legitimately unknown at convert time. @@ -63,6 +65,7 @@ export interface ImportTypeContextMap { "ir/chunitachi": BatchManualContext; "ir/beatoraja": BeatorajaContext; "ir/usc": IRUSCContext; + "ir/kshook-sv3c": EmptyObject; "api/arc-iidx": EmptyObject; "api/arc-sdvx": EmptyObject; diff --git a/server/src/lib/score-import/import-types/converters.ts b/server/src/lib/score-import/import-types/converters.ts index 097857dd5..1960b7108 100644 --- a/server/src/lib/score-import/import-types/converters.ts +++ b/server/src/lib/score-import/import-types/converters.ts @@ -12,6 +12,7 @@ import { ConverterIRBarbatos } from "./ir/barbatos/converter"; import { ConverterIRBeatoraja } from "./ir/beatoraja/converter"; import { ConverterIRFervidexStatic } from "./ir/fervidex-static/converter"; import { ConverterIRFervidex } from "./ir/fervidex/converter"; +import { ConverterIRKShookSV3C } from "./ir/kshook-sv3c/converter"; import { ConverterIRUSC } from "./ir/usc/converter"; export type ConverterMap = { @@ -40,4 +41,5 @@ export const Converters: ConverterMap = { "ir/direct-manual": ConverterBatchManual, "ir/usc": ConverterIRUSC, "ir/chunitachi": ConverterBatchManual, + "ir/kshook-sv3c": ConverterIRKShookSV3C, }; diff --git a/server/src/lib/score-import/import-types/ir/beatoraja/converter.ts b/server/src/lib/score-import/import-types/ir/beatoraja/converter.ts index 36acf1dad..062897cb7 100644 --- a/server/src/lib/score-import/import-types/ir/beatoraja/converter.ts +++ b/server/src/lib/score-import/import-types/ir/beatoraja/converter.ts @@ -12,7 +12,7 @@ import { BeatorajaContext, BeatorajaScore, BeatorajaChart } from "./types"; import { ChartDocument, SongDocument } from "tachi-common"; import { HandleOrphanQueue } from "lib/orphan-queue/orphan-queue"; import { Random20Hex } from "utils/misc"; -import { ServerConfig, ServerTypeInfo } from "lib/setup/config"; +import { ServerConfig, TachiConfig } from "lib/setup/config"; const LAMP_LOOKUP = { NoPlay: "NO PLAY", @@ -56,9 +56,7 @@ export const ConverterIRBeatoraja: ConverterFunction { - if (ServerConfig.TYPE === "btchi" || ServerConfig.TYPE === "omni") { + if (TachiConfig.TYPE === "btchi" || TachiConfig.TYPE === "omni") { return next(); } @@ -23,7 +23,7 @@ export const RequireBokutachi: RequestHandler = (req, res, next) => { * this restriction is bypassed. */ export const RequireKamaitachi: RequestHandler = (req, res, next) => { - if (ServerConfig.TYPE === "ktchi" || ServerConfig.TYPE === "omni") { + if (TachiConfig.TYPE === "ktchi" || TachiConfig.TYPE === "omni") { return next(); } diff --git a/server/src/server/router/api/v1/admin/router.ts b/server/src/server/router/api/v1/admin/router.ts index 425bf1927..a32d3f140 100644 --- a/server/src/server/router/api/v1/admin/router.ts +++ b/server/src/server/router/api/v1/admin/router.ts @@ -6,7 +6,7 @@ import CreateLogCtx, { ChangeRootLogLevel, GetLogLevel } from "lib/logger/logger import prValidate from "server/middleware/prudence-validate"; import { GetUserWithID } from "utils/user"; import { ONE_MINUTE } from "lib/constants/time"; -import { ServerConfig, ServerTypeInfo } from "lib/setup/config"; +import { ServerConfig, TachiConfig } from "lib/setup/config"; import { Game, UserAuthLevels } from "tachi-common"; import db from "external/mongo/db"; @@ -115,7 +115,7 @@ router.post( "/deprimarify", prValidate({ chartID: "*string", - game: p.isIn(ServerTypeInfo.supportedGames), + game: p.isIn(TachiConfig.GAMES), songID: p.optional(p.isPositiveNonZeroInteger), }), async (req, res) => { diff --git a/server/src/server/router/api/v1/auth/router.ts b/server/src/server/router/api/v1/auth/router.ts index dccc3493b..0682c5b3b 100644 --- a/server/src/server/router/api/v1/auth/router.ts +++ b/server/src/server/router/api/v1/auth/router.ts @@ -26,7 +26,7 @@ import { SendEmail } from "lib/email/client"; import { EmailFormatResetPassword, EmailFormatVerifyEmail } from "lib/email/formats"; import { Random20Hex } from "utils/misc"; import { Environment, ServerConfig } from "lib/setup/config"; -import { integer } from ".pnpm/tachi-common@0.2.36/node_modules/tachi-common"; +import { integer } from "tachi-common"; const logger = CreateLogCtx(__filename); diff --git a/server/src/server/router/api/v1/games/_game/middleware.ts b/server/src/server/router/api/v1/games/_game/middleware.ts index eaa50a1ce..bc1f33244 100644 --- a/server/src/server/router/api/v1/games/_game/middleware.ts +++ b/server/src/server/router/api/v1/games/_game/middleware.ts @@ -1,5 +1,5 @@ import { RequestHandler } from "express"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { IsValidGame } from "utils/misc"; import { AssignToReqTachiData } from "utils/req-tachi-data"; @@ -9,7 +9,7 @@ export const ValidateGameFromParam: RequestHandler = (req, res, next) => { success: false, description: `Invalid/unsupported game ${ req.params.game - } - Expected any of ${ServerTypeInfo.supportedGames.join(", ")}`, + } - Expected any of ${TachiConfig.GAMES.join(", ")}`, }); } diff --git a/server/src/server/router/api/v1/games/router.test.ts b/server/src/server/router/api/v1/games/router.test.ts index 37290568f..5fad61e8b 100644 --- a/server/src/server/router/api/v1/games/router.test.ts +++ b/server/src/server/router/api/v1/games/router.test.ts @@ -1,6 +1,6 @@ import { GetGameConfig } from "tachi-common"; import t from "tap"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import mockApi from "test-utils/mock-api"; @@ -9,10 +9,10 @@ t.test("GET /api/v1/games", async (t) => { // and also returns configs properly. const res = await mockApi.get("/api/v1/games"); - t.strictSame(res.body.body.supportedGames, ServerTypeInfo.supportedGames); + t.strictSame(res.body.body.supportedGames, TachiConfig.GAMES); t.strictSame(res.body.body.configs.iidx, GetGameConfig("iidx")); - t.equal(Object.keys(res.body.body.configs).length, ServerTypeInfo.supportedGames.length); + t.equal(Object.keys(res.body.body.configs).length, TachiConfig.GAMES.length); t.end(); }); diff --git a/server/src/server/router/api/v1/games/router.ts b/server/src/server/router/api/v1/games/router.ts index b85e13205..b74f08aad 100644 --- a/server/src/server/router/api/v1/games/router.ts +++ b/server/src/server/router/api/v1/games/router.ts @@ -1,5 +1,5 @@ import { Router } from "express"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { GetGameConfig } from "tachi-common"; import gameRouter from "./_game/router"; @@ -13,15 +13,13 @@ const router: Router = Router({ mergeParams: true }); */ router.get("/", (req, res) => { // this line is a bit too 'smart' for its own good, but whatever. - const configs = Object.fromEntries( - ServerTypeInfo.supportedGames.map((e) => [e, GetGameConfig(e)]) - ); + const configs = Object.fromEntries(TachiConfig.GAMES.map((e) => [e, GetGameConfig(e)])); return res.status(200).json({ success: true, - description: `Returned support information for ${ServerTypeInfo.supportedGames.length} game(s).`, + description: `Returned support information for ${TachiConfig.GAMES.length} game(s).`, body: { - supportedGames: ServerTypeInfo.supportedGames, + supportedGames: TachiConfig.GAMES, configs, }, }); diff --git a/server/src/server/router/api/v1/import/router.ts b/server/src/server/router/api/v1/import/router.ts index 92f334345..75228efc6 100644 --- a/server/src/server/router/api/v1/import/router.ts +++ b/server/src/server/router/api/v1/import/router.ts @@ -14,7 +14,7 @@ import ParseBatchManual from "lib/score-import/import-types/file/batch-manual/pa import { ParseSolidStateXML } from "lib/score-import/import-types/file/solid-state-squad/parser"; import { ParseMerIIDX } from "lib/score-import/import-types/file/mer-iidx/parser"; import ParsePLIIIDXCSV from "lib/score-import/import-types/file/pli-iidx-csv/parser"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { RequirePermissions } from "server/middleware/auth"; import { ParseEagIIDX } from "lib/score-import/import-types/api/eag-iidx/parser"; import { ParseEagSDVX } from "lib/score-import/import-types/api/eag-sdvx/parser"; @@ -34,7 +34,7 @@ const ParseMultipartScoredata = CreateMulterSingleUploadMiddleware( logger ); -const fileImportTypes = ServerTypeInfo.supportedImportTypes.filter((e) => e.startsWith("file/")); +const fileImportTypes = TachiConfig.IMPORT_TYPES.filter((e) => e.startsWith("file/")); /** * Import scores from a file. Expects the post request to be multipart, and to provide a scoreData file. @@ -83,7 +83,7 @@ router.post( } ); -const apiImportTypes = ServerTypeInfo.supportedImportTypes.filter((e) => e.startsWith("api/")); +const apiImportTypes = TachiConfig.IMPORT_TYPES.filter((e) => e.startsWith("api/")); /** * Import scores from another API. This typically will perform a full sync. diff --git a/server/src/server/server.ts b/server/src/server/server.ts index 2e3d5ab6a..f17697fe4 100644 --- a/server/src/server/server.ts +++ b/server/src/server/server.ts @@ -3,7 +3,7 @@ import "express-async-errors"; import expressSession from "express-session"; import { integer } from "tachi-common"; import { RedisClient } from "external/redis/redis"; -import { Environment, ServerConfig } from "lib/setup/config"; +import { Environment, ServerConfig, TachiConfig } from "lib/setup/config"; import connectRedis from "connect-redis"; import helmet from "helmet"; import CreateLogCtx from "lib/logger/logger"; @@ -19,7 +19,7 @@ if (Environment.nodeEnv !== "test") { host: "localhost", port: 6379, client: RedisClient, - prefix: ServerConfig.TYPE, + prefix: TachiConfig.NAME, }); } @@ -27,7 +27,7 @@ const userSessionMiddleware = expressSession({ // append node_env onto the end of the session name // so we can separate tokens under the same URL. // say for staging.kamaitachi.xyz - name: `${ServerConfig.TYPE}_${Environment.nodeEnv}_session`, + name: `${TachiConfig.NAME} (${Environment.nodeEnv}) SESSION`, secret: ServerConfig.SESSION_SECRET, store, resave: true, diff --git a/server/src/utils/misc.ts b/server/src/utils/misc.ts index 7190fecae..3fa7385f4 100644 --- a/server/src/utils/misc.ts +++ b/server/src/utils/misc.ts @@ -1,5 +1,5 @@ import crypto from "crypto"; -import { ServerTypeInfo } from "lib/setup/config"; +import { TachiConfig } from "lib/setup/config"; import { Game, Playtypes, GetGameConfig, GamePTConfig } from "tachi-common"; // https://github.com/sindresorhus/escape-string-regexp/blob/main/index.js @@ -62,7 +62,7 @@ export function HasOwnProperty(obj: T, key: string | number | symbol): key is } export function IsValidGame(str: string): str is Game { - return !!ServerTypeInfo.supportedGames.includes(str as Game); + return !!TachiConfig.GAMES.includes(str as Game); } export function IsValidPlaytype(game: Game, str: string): str is Playtypes[Game] {