Slight restructure, updated auth, implement player and game endpoints

This commit is contained in:
jd
2026-02-18 21:32:28 +00:00
parent 99c7bdc0fd
commit 2996a2eb95
32 changed files with 2093 additions and 266 deletions

View File

@@ -0,0 +1,75 @@
import { hashIds } from './guard';
export interface LoginRequest {
username: string;
password: string;
}
export interface ChangePasswordRequest {
oldPassword: string | null;
newPassword: string;
}
export interface CreateUserRequest {
username: string;
password: string;
playerId: string;
}
export interface UpdateUserRequest {
isActive?: boolean;
isAdmin?: boolean;
}
export interface CreatePlayerRequest {
name: string;
}
export interface UpdatePlayerRequest {
name?: string;
isRatingLocked?:boolean;
canBeMultiple?:boolean;
}
export interface CreateGameRequest {
name: string;
imagePath?: string;
bggId?: string;
}
export interface UpdateGameRequest {
name: string;
imagePath?: string;
bggId?: string;
}
export class SecureId {
#hashedValue?: string;
#secureValue?: string;
get value(): string | undefined {
return this.#hashedValue;
}
set value(value: string) {
this.#hashedValue = value;
this.#secureValue = hashIds.decode(value)?.toString();
}
get raw(): string | undefined {
return this.#secureValue;
}
set raw(value: string) {
this.#hashedValue = hashIds.encode(value);
this.#secureValue = value;
}
constructor(id: { public?: string; secure?: string }) {
if (id.public) {
this.value = id.public;
} else if (id.secure) {
this.raw = id.secure;
}
}
toJSON(): string | undefined {
return this.#hashedValue;
}
public static fromHash(hash: string) {
return new SecureId({ public: hash });
}
public static fromID(id: string) {
return new SecureId({ secure: id });
}
}