feat: bud-04 (mirror)

feat: migrate void.cat
This commit is contained in:
2024-12-16 17:20:26 +00:00
parent 5e92134b5c
commit c024cd4a4e
10 changed files with 228 additions and 74 deletions

View File

@ -50,6 +50,18 @@ export class Blossom {
}
}
async mirror(url: string) {
const rsp = await this.#req("mirror", "PUT", "mirror", JSON.stringify({ url }), undefined, {
"content-type": "application/json"
});
if (rsp.ok) {
return (await rsp.json()) as BlobDescriptor;
} else {
const text = await rsp.text();
throw new Error(text);
}
}
async list(pk: string) {
const rsp = await this.#req(`list/${pk}`, "GET", "list");
if (rsp.ok) {
@ -76,6 +88,7 @@ export class Blossom {
term: string,
body?: BodyInit,
tags?: Array<Array<string>>,
headers?: Record<string, string>,
) {
throwIfOffline();
@ -100,6 +113,7 @@ export class Blossom {
method,
body,
headers: {
...headers,
accept: "application/json",
authorization: await auth(url, method),
},