refactor(backend): move every route to its own module

This commit is contained in:
Haileyesus
2026-03-27 18:26:30 +03:00
parent 8986bc10a5
commit f77301e844
24 changed files with 9082 additions and 17 deletions

View File

@@ -0,0 +1,30 @@
import express from 'express';
import { notificationPreferencesDb } from '../../../database/db.js';
const router = express.Router();
// ===============================
// Notification Preferences
// ===============================
router.get('/', async (req, res) => {
try {
const preferences = notificationPreferencesDb.getPreferences(req.user.id);
res.json({ success: true, preferences });
} catch (error) {
console.error('Error fetching notification preferences:', error);
res.status(500).json({ error: 'Failed to fetch notification preferences' });
}
});
router.put('/', async (req, res) => {
try {
const preferences = notificationPreferencesDb.updatePreferences(req.user.id, req.body || {});
res.json({ success: true, preferences });
} catch (error) {
console.error('Error saving notification preferences:', error);
res.status(500).json({ error: 'Failed to save notification preferences' });
}
});
export default router;