buddy-workbench 0.1.34 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import express, { Router } from 'express';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
3
|
import { clipboardDates, clipboardItems, clipboardOriginal, deleteClipboardItem, saveClipboardImage, clipboardImagePath, allTaggedClipboardItems, updateClipboardItemTags, markClipboardCopied } from '../services/clipboard-history.js';
|
|
3
4
|
|
|
4
5
|
const router = Router();
|
|
@@ -23,7 +24,10 @@ router.post('/image', express.raw({ type: 'image/*', limit: '10mb' }), (req, res
|
|
|
23
24
|
router.get('/image/:filename', (req, res) => {
|
|
24
25
|
try {
|
|
25
26
|
const filePath = clipboardImagePath(req.params.filename);
|
|
26
|
-
|
|
27
|
+
if (!existsSync(filePath)) {
|
|
28
|
+
return res.status(404).json({ error: 'Image not found.' });
|
|
29
|
+
}
|
|
30
|
+
res.type(filePath).send(readFileSync(filePath));
|
|
27
31
|
} catch (error) {
|
|
28
32
|
res.status(404).json({ error: 'Image not found.' });
|
|
29
33
|
}
|
|
@@ -46,4 +50,3 @@ router.post('/:date/:id/copied', async (req, res) => {
|
|
|
46
50
|
});
|
|
47
51
|
router.delete('/:date/:id', (req, res) => { if (!deleteClipboardItem(req.params.date, req.params.id)) return res.status(404).json({ error: 'Clipboard entry not found.' }); res.status(204).end(); });
|
|
48
52
|
export default router;
|
|
49
|
-
|