Some Code Cleanup
This commit is contained in:
@ -19,7 +19,8 @@
|
||||
|
||||
import type {Player, Server} from "@type/data.ts";
|
||||
import {PlayerSchema, ServerSchema} from "@type/data.ts";
|
||||
import {fetchWithToken} from "./repo.ts";
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class DataRepo {
|
||||
constructor(private token: string) {}
|
||||
@ -31,4 +32,6 @@ export class DataRepo {
|
||||
public async getMe(): Promise<Player> {
|
||||
return await fetchWithToken(this.token, "/data/me").then(value => value.json()).then(PlayerSchema.parse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const dataRepo = derived(tokenStore, ($token) => new DataRepo($token));
|
||||
Reference in New Issue
Block a user