Improved network service error handling

This commit is contained in:
Alex Holliday committed 2024-06-18 11:42:25 -07:00
1 parent d4012e1f19
commit 59562b10c9
5 files changed
+91 -33

No files matched your search

+13
View File
@@ -180,6 +180,18 @@ const deleteMonitor = async (req, res, next) => {
}
};
const deleteAllMonitors = async (req, res) => {
try {
const deleteCount = await req.db.deleteAllMonitors();
return res
.status(200)
.json({ success: true, msg: `Deleted ${deleteCount} monitors` });
} catch (error) {
error.service = SERVICE_NAME;
next(error);
}
};
/**
* Edit a monitor by ID
* @async
@@ -219,5 +231,6 @@ module.exports = {
getMonitorsByUserId,
createMonitor,
deleteMonitor,
deleteAllMonitors,
editMonitor,
};