chore: some upgrade
All checks were successful
Deploy to SFTP Server / build (push) Successful in 22m39s

This commit is contained in:
Max Richter
2025-10-28 17:36:09 +01:00
parent 6545a25741
commit 24d01e44b0
5 changed files with 65 additions and 62 deletions

View File

@@ -23,27 +23,33 @@ export type MemoriumEntry = MemoriumFile | MemoriumDir;
const SERVER_URL = "https://marka.max-richter.dev";
//const SERVER_URL = "http://localhost:8080";
const cache = {};
export async function listResource(
id: string,
): Promise<MemoriumEntry | undefined> {
const url = `${SERVER_URL}/resources/${id}`;
console.log(url);
if (cache[url]) return cache[url];
try {
const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
if (response.ok) {
const json = await response.json();
if (json.type == "dir") {
return {
const res = {
...json,
content: json.content.filter((res: MemoriumEntry) =>
res.mime === "application/markdown"
),
};
cache[url] = res;
return res;
}
cache[url] = json;
return json;
}
} catch (_e) {
console.log("Failed to get: ", url);
cache[url] = undefined;
return;
}
}