Update Backend

This commit is contained in:
2024-11-23 13:28:33 +01:00
parent e70951c9dd
commit cb65e96165
23 changed files with 493 additions and 310 deletions

View File

@@ -33,19 +33,19 @@ export const schemTypes = cached<SchematicType[]>([], () =>
.then(res => res.json()));
export const players = cached<Player[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), "/data/users");
const res = await fetchWithToken(get(tokenStore), "/data/admin/users");
return z.array(PlayerSchema).parse(await res.json());
});
export const gamemodes = cached<string[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), "/data/gamemodes");
const res = await fetchWithToken(get(tokenStore), "/data/admin/gamemodes");
return z.array(z.string()).parse(await res.json());
});
export const maps = cachedFamily<string, string[]>([], async (gamemode) => {
if (get(gamemodes).every(value => value !== gamemode)) return [];
const res = await fetchWithToken(get(tokenStore), `/data/gamemodes/${gamemode}/maps`);
const res = await fetchWithToken(get(tokenStore), `/data/admin/gamemodes/${gamemode}/maps`);
if (!res.ok) {
return [];
} else {
@@ -54,7 +54,7 @@ export const maps = cachedFamily<string, string[]>([], async (gamemode) => {
});
export const groups = cached<string[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), "/data/groups");
const res = await fetchWithToken(get(tokenStore), "/data/admin/groups");
return z.array(z.string()).parse(await res.json());
});