2024-05-19 03:07:35 +00:00
|
|
|
import {
|
|
|
|
fetchAlerts,
|
|
|
|
createAlert,
|
|
|
|
removeAlert,
|
2024-05-20 04:29:10 +00:00
|
|
|
fetchNotifications,
|
2024-05-19 03:07:35 +00:00
|
|
|
updateNotifications,
|
|
|
|
updateNotification,
|
|
|
|
} from '../alerts.js';
|
|
|
|
|
|
|
|
export async function fetchAlertsApi(req, res) {
|
|
|
|
const alerts = await fetchAlerts(req.user);
|
|
|
|
|
|
|
|
res.send(alerts);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function createAlertApi(req, res) {
|
|
|
|
const alertId = await createAlert(req.body, req.user);
|
|
|
|
|
|
|
|
res.send({ id: alertId });
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function removeAlertApi(req, res) {
|
|
|
|
await removeAlert(req.params.alertId, req.user);
|
|
|
|
|
|
|
|
res.status(204).send();
|
|
|
|
}
|
|
|
|
|
2024-05-20 04:29:10 +00:00
|
|
|
export async function fetchNotificationsApi(req, res) {
|
|
|
|
const notifications = await fetchNotifications(req.user, {
|
|
|
|
limit: req.query.limit || 10,
|
|
|
|
});
|
|
|
|
|
|
|
|
res.send(notifications);
|
|
|
|
}
|
|
|
|
|
2024-05-19 03:07:35 +00:00
|
|
|
export async function updateNotificationsApi(req, res) {
|
|
|
|
await updateNotifications(req.body, req.user);
|
|
|
|
|
|
|
|
res.status(204).send();
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function updateNotificationApi(req, res) {
|
|
|
|
await updateNotification(req.params.notificationId, req.body, req.user);
|
|
|
|
|
|
|
|
res.status(204).send();
|
|
|
|
}
|