add /clear endpoint for data cleanup
This commit is contained in:
14
index.js
14
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, () => {
|
||||
|
||||
Reference in New Issue
Block a user