feat: archiving

This commit is contained in:
2025-11-15 10:56:16 +01:00
parent 2ba84c3ccf
commit 862e5dafaf
4 changed files with 400 additions and 27 deletions

View File

@@ -642,6 +642,32 @@ app.post('/api/links', async (req, res) => {
}
});
// Archive/Unarchive a link
app.patch('/api/links/:id/archive', async (req, res) => {
try {
const { id } = req.params;
const { archived } = req.body;
if (typeof archived !== 'boolean') {
return res.status(400).json({ error: 'archived must be a boolean' });
}
const links = await readLinks();
const linkIndex = links.findIndex(link => link.id === id);
if (linkIndex === -1) {
return res.status(404).json({ error: 'Link not found' });
}
links[linkIndex].archived = archived;
await writeLinks(links);
res.json(links[linkIndex]);
} catch (error) {
res.status(500).json({ error: 'Failed to update link' });
}
});
// Delete a link
app.delete('/api/links/:id', async (req, res) => {
try {