u
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user