Some Code Cleanup
This commit is contained in:
@@ -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));
|
||||
Reference in New Issue
Block a user