Code-Schnipsel History: Aktuell ganz oben, korrekter Diff, History-Einträge löschbar

This commit is contained in:
2026-05-29 14:07:39 +02:00
parent ce1449d21f
commit 05450e2b7e
2 changed files with 105 additions and 37 deletions

View File

@@ -98,6 +98,13 @@ router.put('/:id', authenticate, (req, res) => {
});
// ── Löschen ──────────────────────────────────────────────────────────────────
router.delete('/:id/history/:hid', authenticate, (req, res) => {
const s = db.prepare('SELECT * FROM snippets WHERE id=? AND user_id=?').get(req.params.id, uid(req));
if (!s) return res.status(403).json({ error: 'Kein Zugriff' });
db.prepare('DELETE FROM snippet_history WHERE id=? AND snippet_id=?').run(req.params.hid, s.id);
res.json({ ok: true });
});
router.delete('/:id', authenticate, (req, res) => {
const r = db.prepare('DELETE FROM snippets WHERE id=? AND user_id=?').run(req.params.id, uid(req));
if (!r.changes) return res.status(404).json({ error: 'Nicht gefunden' });