Add notifications to monitors before returning

This commit is contained in:
Alex Holliday committed 2024-07-31 20:20:04 -07:00
1 parent 7f35a6b922
commit b126830110
1 file changed
+7 -1
+7 -1
View File
@@ -2,6 +2,7 @@ const Monitor = require("../../../models/Monitor");
const Check = require("../../../models/Check");
const PageSpeedCheck = require("../../../models/PageSpeedCheck");
const { errorMessages } = require("../../../utils/messages");
const Notification = require("../../../models/Notification");
/**
* Get all monitors
@@ -119,7 +120,12 @@ const getMonitorsByUserId = async (req, res) => {
createdAt: sortOrder,
})
.limit(limit);
return { ...monitor.toObject(), checks };
// Get notifications
const notifications = await Notification.find({
monitorId: monitor._id,
});
return { ...monitor.toObject(), checks, notifications };
})
);
return monitorsWithChecks;