From: xangelo Date: Fri, 26 Jan 2024 20:03:02 +0000 (-0500) Subject: delete feeds X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=9c441c3ba9dfb811e5f3b80440c8369fcf3e7de9;p=river.git delete feeds --- diff --git a/src/server.ts b/src/server.ts index 5b32531..0c93175 100644 --- a/src/server.ts +++ b/src/server.ts @@ -173,7 +173,19 @@ app.post('/feeds', async (req, res) => { app.get('/feeds', async (req, res) => { res.json(await db.select('*').from('feeds').orderBy('created_at')); -}) +}); + +app.delete('/feeds/:feed_id', async (req, res) => { + if(req.query.key !== process.env.ADMIN_KEY) { + res.sendStatus(400).end(); + return; + } + + await db('feeds').delete().where({ id: req.params.feed_id }); + await db('feed_entry').delete().where({ feed_id: req.params.feed_id }); + + res.json(await db.select('*').from('feeds').orderBy('created_at')); +}); app.listen(process.env.API_PORT, () => { console.log(`Listening on port ${process.env.API_PORT}`);