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,10 +18,11 @@
*/
import type {Page, PageList} from "@type/page.ts";
import {fetchWithToken} from "./repo.ts";
import {fetchWithToken, tokenStore} from "./repo.ts";
import {PageListSchema, PageSchema} from "@type/page.ts";
import {bytesToBase64} from "../admin/util.ts";
import {z} from "zod";
import {derived} from "svelte/store";
export class PageRepo {
constructor(private token: string) {}
@ -74,4 +75,6 @@ export class PageRepo {
public async deletePage(id: number, message: string, sha: string, branch: string = "master"): Promise<void> {
await fetchWithToken(this.token, `/page/${id}?branch=${branch}`, {method: "DELETE", body: JSON.stringify({message, sha})});
}
}
}
export const pageRepo = derived(tokenStore, ($token) => new PageRepo($token));