Some Code Cleanup

This commit is contained in:
2023-12-27 19:16:54 +01:00
parent 3108d9bf20
commit 9a16c4b560
38 changed files with 87 additions and 105 deletions

View File

@@ -18,8 +18,9 @@
*/
import type {FightStats, Ranking, UserStats} from "@type/stats.ts";
import {fetchWithToken} from "./repo.ts";
import {fetchWithToken, tokenStore} from "./repo.ts";
import {FightStatsSchema, RankingSchema, UserStatsSchema} from "@type/stats.ts";
import {derived} from "svelte/store";
export class StatsRepo {
@@ -36,4 +37,6 @@ export class StatsRepo {
public async getUserStats(id: number): Promise<UserStats> {
return await fetchWithToken(this.token, `/stats/user/${id}`).then(value => value.json()).then(UserStatsSchema.parse);
}
}
}
export const statsRepo = derived(tokenStore, ($token) => new StatsRepo($token));