This commit is contained in:
seb
2026-08-01 01:36:54 +02:00
parent c77337507f
commit 60d623f7df
2 changed files with 23 additions and 8 deletions

View File

@@ -19,11 +19,6 @@ function articleErrorStatus(error) {
return 500;
}
function isLikelyImageDecodeError(error) {
const msg = error?.message || '';
return /unsupported|corrupt|invalid|input buffer|vips/i.test(msg);
}
/**
* Registers article routes (requires auth middleware).
* @param {import('express').Application} app - Express app
@@ -346,9 +341,6 @@ export function register(app, basePath = '') {
const image = await db.addImage(req.user.id, decodeURIComponent(sku), imageBuffer);
res.status(201).json({ image });
} catch (error) {
if (isLikelyImageDecodeError(error)) {
return res.status(400).json({ error: 'Invalid image' });
}
const status = articleErrorStatus(error);
if (status === 500) console.error('Add article image failed:', error);
res.status(status).json({ error: error.message });