mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-15 05:36:11 +01:00
28 lines
884 B
TypeScript
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;
|
|
}
|
|
}
|