diff --git a/Server/controllers/monitorController.js b/Server/controllers/monitorController.js index 06dcb9998..0615578c4 100644 --- a/Server/controllers/monitorController.js +++ b/Server/controllers/monitorController.js @@ -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} + * @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,