35 lines
817 B
JavaScript
Executable File
35 lines
817 B
JavaScript
Executable File
'use strict';
|
|
|
|
const { addAlert, removeAlert, updateNotifications, updateNotification } = require('../alerts');
|
|
|
|
async function addAlertApi(req, res) {
|
|
const alertId = await addAlert(req.body, req.session.user);
|
|
|
|
res.send({ id: alertId });
|
|
}
|
|
|
|
async function removeAlertApi(req, res) {
|
|
await removeAlert(req.params.alertId);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
async function updateNotificationsApi(req, res) {
|
|
await updateNotifications(req.body, req.session.user);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
async function updateNotificationApi(req, res) {
|
|
await updateNotification(req.params.notificationId, req.body, req.session.user);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
module.exports = {
|
|
addAlert: addAlertApi,
|
|
removeAlert: removeAlertApi,
|
|
updateNotifications: updateNotificationsApi,
|
|
updateNotification: updateNotificationApi,
|
|
};
|