Remove tag handling routes from server.js and use only tasks.js

Fix #22
This commit is contained in:
2025-02-02 19:28:31 +01:00
parent 37a7e5e67a
commit 4fc8e81e97

View File

@@ -51,34 +51,7 @@ app.use(session({
app.use('/', authRouter);
app.use('/', authMiddleware, tasksRouter);
// Add routes for handling tags
app.post('/save-tags', authMiddleware, (req, res) => {
const { tags } = req.body;
const placeholders = tags.map(() => '(?)').join(',');
const sql = `INSERT OR IGNORE INTO tags (tag) VALUES ${placeholders}`;
db.run(sql, tags, function(err) {
if (err) {
logger.error('Error saving tags:', err);
res.status(500).send('Error saving tags.');
} else {
res.send({ message: 'Tags saved successfully!' });
logger.info(`New tags saved: ${tags}`);
}
});
});
app.get('/get-tags', authMiddleware, (req, res) => {
db.all('SELECT tag FROM tags', [], (err, rows) => {
if (err) {
logger.error('Error retrieving tags:', err);
res.status(500).json({ error: 'Error retrieving tags' });
} else {
const tags = rows.map(row => row.tag);
res.json(tags);
}
});
});
app.listen(port, () => {
logger.info(`Server running at http://localhost:${port}`);