Merge pull request #604 from bluewave-labs/feat/monitor-details-refactor

Refactored monitor details, resolves #596
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-08-12 12:52:17 -07:00
commit 9629230939
7 files changed
+269 -70

No files matched your search

+33
View File
@@ -33,6 +33,38 @@ const getAllMonitors = async (req, res, next) => {
}
};
/**
* Returns monitor stats for monitor with matching ID
* @async
* @param {Express.Request} req
* @param {Express.Response} res
* @returns {Promise<Express.Response>}
* @throws {Error}
*/
const getMonitorStatsById = async (req, res, next) => {
try {
//Validation
} catch (error) {
error.status = 422;
error.message =
error.details?.[0]?.message || error.message || "Validation Error";
next(error);
return;
}
try {
const monitorStats = await req.db.getMonitorStatsById(req);
return res.json({
success: true,
msg: successMessages.MONTIOR_STATS_BY_ID,
data: monitorStats,
});
} catch (error) {
error.service = SERVICE_NAME;
next(error);
}
};
/**
* Returns monitor with matching ID
* @async
@@ -269,6 +301,7 @@ const editMonitor = async (req, res, next) => {
module.exports = {
getAllMonitors,
getMonitorStatsById,
getMonitorById,
getMonitorsByUserId,
createMonitor,