add export data button to user settings, this lets users export their uploads/favorites at will.

This commit is contained in:
2026-05-12 18:49:28 +02:00
parent 2269da314f
commit 173f9f9e56
7 changed files with 190 additions and 4 deletions

View File

@@ -58,6 +58,25 @@ export default (router, tpl) => {
}, req)
});
});
group.get('/export-data', auth, async (req, res) => {
const uploads = await db`
select id, dest, mime from items
where username = ${req.session.user} and active = true
order by id desc
`;
const favorites = await db`
select i.id, i.dest, i.mime from items i
join favorites f on f.item_id = i.id
where f.user_id = ${+req.session.id} and i.active = true
order by f.item_id desc
`;
res.reply({
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ uploads, favorites })
});
});
});
return router;