Replace notifications with activity feed
This commit is contained in:
30
backend/routes/activityRoutes.js
Normal file
30
backend/routes/activityRoutes.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const express = require('express');
|
||||
|
||||
const createActivityRouter = ({ pool }) => {
|
||||
const router = express.Router();
|
||||
|
||||
const listActivity = async (req, res) => {
|
||||
try {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT id, type, title, message, link, created_at
|
||||
FROM notifications
|
||||
WHERE user_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 50`,
|
||||
[req.user.id]
|
||||
);
|
||||
res.json(rows);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
router.get('/activity', listActivity);
|
||||
router.get('/notifications', listActivity);
|
||||
|
||||
return router;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
createActivityRouter,
|
||||
};
|
||||
Reference in New Issue
Block a user