Files
blitzkit/packages/website-ue/src/core/api/client.ts
T

32 lines
834 B
TypeScript
Raw Normal View History

2025-12-26 14:59:09 -06:00
import { fetchPB } from "@blitzkit/core";
2026-01-12 14:13:21 -06:00
import { Avatars } from "../../protos/avatars";
2025-11-28 13:51:17 -06:00
import { AbstractAPI } from "./abstract";
2025-11-30 22:12:46 -06:00
export class ClientAPI extends AbstractAPI {
2026-01-12 14:13:21 -06:00
protected _avatars() {
return fetchPB("/api/avatars/all.pb", Avatars);
2025-11-30 22:12:46 -06:00
}
2026-01-13 13:30:09 -06:00
protected _gameStrings(): Promise<Record<string, string>> {
throw new Error("Cannot fetch full game strings on client");
}
protected async _groupedGameStrings(
locale: string,
group: string,
prefix: boolean
) {
const response = await fetch(`/api/game-strings/${locale}/${group}.json`);
const json = (await response.json()) as Record<string, string>;
if (!prefix) return json;
const strings: Record<string, string> = {};
for (const key in json) {
strings[`${group}__${key}`] = json[key];
}
return strings;
}
2025-11-30 22:12:46 -06:00
}