Add controller method for getAllMonitorsWithUptimeStats

This commit is contained in:
Alex Holliday committed 2024-11-06 11:16:45 +08:00
1 parent ba37fb3871
commit f613c5f19a
1 file changed
+23
+23
View File
@@ -45,6 +45,28 @@ const getAllMonitors = async (req, res, next) => {
}
};
/**
* Returns all monitors with uptime stats for 1,7,30, and 90 days
* @async
* @param {Express.Request} req
* @param {Express.Response} res
* @param {function} next
* @returns {Promise<Express.Response>}
* @throws {Error}
*/
const getAllMonitorsWithUptimeStats = async (req, res, next) => {
try {
const monitors = await req.db.getAllMonitorsWithUptimeStats();
return res.status(200).json({
success: true,
msg: successMessages.MONITOR_GET_ALL,
data: monitors,
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "getAllMonitorsWithUptimeStats"));
}
};
/**
* Returns monitor stats for monitor with matching ID
* @async
@@ -495,6 +517,7 @@ const addDemoMonitors = async (req, res, next) => {
export {
getAllMonitors,
getAllMonitorsWithUptimeStats,
getMonitorStatsById,
getMonitorCertificate,
getMonitorById,