From f30ed614e4fbb7233414b8cb7c87fd0c841ef0cb Mon Sep 17 00:00:00 2001 From: Krishna Kumar Date: Wed, 4 Feb 2026 11:50:31 -0600 Subject: [PATCH] add /clear endpoint for data cleanup --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2cbe5b3..26df8fb 100644 --- a/index.js +++ b/index.js @@ -71,7 +71,7 @@ app.use(cors({ } return callback(new Error('Not allowed by CORS')); }, - methods: ['GET', 'POST'], + methods: ['GET', 'POST', 'DELETE'], allowedHeaders: ['Content-Type', 'Authorization'] })); @@ -221,6 +221,18 @@ app.get('/stats', requireAuth, (req, res) => { } }); +// Delete all submissions (protected) +app.delete('/clear', requireAuth, (req, res) => { + try { + db.run('DELETE FROM submissions'); + saveDb(); + res.json({ success: true, message: 'All submissions deleted' }); + } catch (error) { + console.error('Clear error:', error); + res.status(500).json({ error: 'Internal server error' }); + } +}); + // Start server after DB init initDb().then(() => { app.listen(PORT, () => {