fix: dont import node:path in clientside components

This commit is contained in:
Max Richter
2025-10-31 15:41:46 +01:00
parent 7e60327940
commit 79d692c2c6
21 changed files with 68 additions and 67 deletions

View File

@@ -1,5 +1,3 @@
import { MARKA_API_KEY } from "./env.ts";
export const resources = {
"home": {
emoji: "House with Garden.png",
@@ -32,38 +30,3 @@ export const resources = {
prefix: "Media/series/",
},
} as const;
const url = `https://marka.max-richter.dev/resources`;
//const url = "http://localhost:8080/resources";
export async function fetchResource(resource: string) {
try {
const response = await fetch(
`${url}/${resource}`,
);
return response.json();
} catch (_e) {
return [];
}
}
export async function createResource(
path: string,
content: string | object | ArrayBuffer,
) {
const isJson = typeof content === "object";
const fetchUrl = `${url}/${path}`;
console.log("Creating resource", { fetchUrl, content, isJson });
const response = await fetch(fetchUrl, {
method: "POST",
headers: {
"Content-Type": isJson ? "application/json" : "",
"Authentication": MARKA_API_KEY,
},
body: isJson ? JSON.stringify(content) : content,
});
if (!response.ok) {
throw new Error(`Failed to create resource: ${response.status}`);
}
return response.json();
}