mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-25 22:19:28 -04:00
error handling – cleaner logs for invalid image uploads
This commit is contained in:
parent
a734604fec
commit
5b15be1f3b
@ -59,7 +59,11 @@ router.post('/images/upload', multer({limits: {fileSize: 10 * 1024 * 1024}}).any
|
||||
const ids = [];
|
||||
for (let file of req.files) {
|
||||
const id = ulid();
|
||||
const image = await loadImage(await sharp(file.buffer).png().toBuffer());
|
||||
try {
|
||||
const image = await loadImage(await sharp(file.buffer).png().toBuffer());
|
||||
} catch {
|
||||
return res.status(400).json({error: 'File type not supported'});
|
||||
}
|
||||
|
||||
for (let s in sizes) {
|
||||
if (!sizes.hasOwnProperty(s)) { continue; }
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (err, req) => {
|
||||
return `[${new Date().toISOString()}][${req ? (req.method + ' ' + req.url) : ''}] ${err.message || err} ${err.stack}`;
|
||||
return `[${new Date().toISOString()}] [${req ? (req.method + ' ' + req.url) : ''}] ${err.message || err} ${err.stack}`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user