New Code Editor and fun
This commit is contained in:
20
src/components/repo/stats.ts
Normal file
20
src/components/repo/stats.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user