38 lines
792 B
JavaScript
38 lines
792 B
JavaScript
|
import {
|
||
|
fetchAlerts,
|
||
|
createAlert,
|
||
|
removeAlert,
|
||
|
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();
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
}
|