rename SYMBOL_TachiAPIData to TachiAPIAuth

This commit is contained in:
zkldi
2021-06-16 20:11:17 +01:00
parent 4760df19d9
commit 0248e4e5de
19 changed files with 213 additions and 48 deletions
+11
View File
@@ -1,4 +1,7 @@
import crypto from "crypto";
import { CONF_INFO } from "../lib/setup/config";
import { Game, Playtypes } from "tachi-common";
import { validPlaytypes } from "tachi-common/js/config";
// https://github.com/sindresorhus/escape-string-regexp/blob/main/index.js
// the developer of this has migrated everything to Force ES6 style modules,
@@ -58,3 +61,11 @@ export function SplitAuthorizationHeader(authHeader: string) {
export function HasOwnProperty<T>(obj: T, key: string | number | symbol): key is keyof T {
return Object.prototype.hasOwnProperty.call(obj, key);
}
export function IsValidGame(str: string): str is Game {
return !!CONF_INFO.SUPPORTED_GAMES.includes(str as Game);
}
export function IsValidPlaytype(game: Game, str: string): str is Playtypes[Game] {
return validPlaytypes[game].includes(str as Playtypes[Game]);
}
+4 -1
View File
@@ -1,4 +1,4 @@
import { integer, ChartDocument } from "tachi-common";
import { integer, ChartDocument, PublicUserDocument, UserGameStats } from "tachi-common";
declare module "express-session" {
// Inject additional properties on express-session
@@ -36,4 +36,7 @@ export interface TachiRequestData {
uscChartDoc?: ChartDocument<"usc:Single">;
beatorajaChartDoc?: ChartDocument<"bms:7K" | "bms:14K">;
requestedUser?: PublicUserDocument;
requestedUserGameStats?: UserGameStats;
}