Files
blitzkit/packages/website-ue/src/core/api/client.ts
T
2026-01-15 13:58:34 -06:00

28 lines
884 B
TypeScript

import { fetchPB } from "@blitzkit/core";
import type { Strings } from "@blitzkit/i18n";
import { Avatars } from "../../protos/avatars";
import { AbstractAPI } from "./abstract";
//@ts-expect-error
export class ClientAPI extends AbstractAPI {
protected _avatars() {
return fetchPB("/api/avatars/all.pb", Avatars);
}
protected _gameStrings(): Promise<Record<string, string>> {
throw new Error("Cannot fetch full game strings on client");
}
protected async _groupedGameStrings(locale: string, group: string) {
const response = await fetch(`/api/game-strings/${locale}/${group}.json`);
const json = (await response.json()) as Record<string, string>;
return json;
}
protected async _strings(locale: string) {
const response = await fetch(`/api/strings/${locale}.json`);
const json = (await response.json()) as Strings;
return json;
}
}