From 7664abe089e1bb31cdfcba37315eeb79ca67b15d Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 4 Nov 2025 16:04:51 +0100 Subject: [PATCH] fix: actually write image --- lib/log/fs.ts | 1 - lib/marka/index.ts | 4 +++- routes/api/articles/create/index.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/log/fs.ts b/lib/log/fs.ts index 237f091..6790d5d 100644 --- a/lib/log/fs.ts +++ b/lib/log/fs.ts @@ -41,7 +41,6 @@ export async function getLogs() { date: new Date(date), } as Log; }); - console.log(logs); // Return the logs sorted by date return logs.sort((a, b) => a.date.getTime() - b.date.getTime()); diff --git a/lib/marka/index.ts b/lib/marka/index.ts index b4a9d6e..c6b3371 100644 --- a/lib/marka/index.ts +++ b/lib/marka/index.ts @@ -102,7 +102,9 @@ export async function createResource( body: isJson ? JSON.stringify(content) : content, }); if (!response.ok) { - throw new Error(`Failed to create resource: ${response.status}`); + throw new Error( + `Failed to create resource (resources/${path}) : ${response.status}`, + ); } return response.json(); } diff --git a/routes/api/articles/create/index.ts b/routes/api/articles/create/index.ts index aa34a16..46ff098 100644 --- a/routes/api/articles/create/index.ts +++ b/routes/api/articles/create/index.ts @@ -52,7 +52,7 @@ async function processCreateArticle( let finalPath = result.image; if (result?.image) { const extension = fileExtension(result?.image); - const imagePath = `resources/articles/images/${ + const imagePath = `articles/images/${ safeFileName(title) }_cover.${extension}`; try { @@ -63,7 +63,7 @@ async function processCreateArticle( await createResource(imagePath, buffer); finalPath = imagePath; } catch (err) { - console.log("Failed to save image", err); + console.log(`Failed to save image: ${result.image}`, err); } }