New Code Editor and fun

This commit is contained in:
2023-12-03 19:31:29 +01:00
parent 2abe554059
commit fbd52f3edb
53 changed files with 1330 additions and 489 deletions

View File

@@ -0,0 +1,20 @@
import type {FightStats, Ranking, UserStats} from "../types/stats.ts";
import {fetchWithToken} from "./repo.ts";
import {FightStatsSchema, RankingSchema, UserStatsSchema} from "../types/stats.ts";
export class StatsRepo {
constructor(private token: string) {}
public async getRankings(gamemode: string): Promise<Ranking> {
return await fetchWithToken(this.token, `/stats/ranked/${gamemode}`).then(value => value.json()).then(RankingSchema.parse);
}
public async getFightStats(): Promise<FightStats> {
return await fetchWithToken(this.token, `/stats/fights`).then(value => value.json()).then(FightStatsSchema.parse);
}
public async getUserStats(id: number): Promise<UserStats> {
return await fetchWithToken(this.token, `/stats/user/${id}`).then(value => value.json()).then(UserStatsSchema.parse);
}
}