Add safety check for monitor

This commit is contained in:
Alex Holliday committed 2024-08-31 16:48:02 -07:00
1 parent d1add402b0
commit 8ac53a9e16
3 files changed
+41 -30

No files matched your search

+3
View File
@@ -280,6 +280,9 @@ const getMonitorStatsById = async (req) => {
const getMonitorById = async (monitorId) => {
try {
const monitor = await Monitor.findById(monitorId);
if (monitor === null || monitor === undefined) {
throw new Error(errorMessages.DB_FIND_MONTIOR_BY_ID(monitorId));
}
// Get notifications
const notifications = await Notification.find({
monitorId: monitorId,