From 9c441c3ba9dfb811e5f3b80440c8369fcf3e7de9 Mon Sep 17 00:00:00 2001 From: xangelo Date: Fri, 26 Jan 2024 15:03:02 -0500 Subject: [PATCH] delete feeds --- src/server.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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}`); -- 2.25.1