Add safety check for monitor
This commit is contained in:
1 parent
d1add402b0
commit
8ac53a9e16
3 files changed
+41
-30
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user