add jsdoc and validation
This commit is contained in:
1 parent
c572096a50
commit
6563cedf88
2 files changed
+28
No files matched your search
@@ -12,6 +12,8 @@ import {
|
|||||||
getMonitorStatsByIdParamValidation,
|
getMonitorStatsByIdParamValidation,
|
||||||
getMonitorStatsByIdQueryValidation,
|
getMonitorStatsByIdQueryValidation,
|
||||||
getCertificateParamValidation,
|
getCertificateParamValidation,
|
||||||
|
getHardwareDetailsByIdParamValidation,
|
||||||
|
getHardwareDetailsByIdQueryValidation,
|
||||||
} from "../validation/joi.js";
|
} from "../validation/joi.js";
|
||||||
import sslChecker from "ssl-checker";
|
import sslChecker from "ssl-checker";
|
||||||
import { successMessages } from "../utils/messages.js";
|
import { successMessages } from "../utils/messages.js";
|
||||||
@@ -104,7 +106,23 @@ class MonitorController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get hardware details for a specific monitor by ID
|
||||||
|
* @async
|
||||||
|
* @param {Express.Request} req - Express request object containing monitorId in params
|
||||||
|
* @param {Express.Response} res - Express response object
|
||||||
|
* @param {Express.NextFunction} next - Express next middleware function
|
||||||
|
* @returns {Promise<Express.Response>}
|
||||||
|
* @throws {Error} - Throws error if monitor not found or other database errors
|
||||||
|
*/
|
||||||
getHardwareDetailsById = async (req, res, next) => {
|
getHardwareDetailsById = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
await getHardwareDetailsByIdParamValidation.validateAsync(req.params);
|
||||||
|
await getHardwareDetailsByIdQueryValidation.validateAsync(req.query);
|
||||||
|
} catch (error) {
|
||||||
|
next(handleValidationError(error, SERVICE_NAME));
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const monitor = await this.db.getHardwareDetailsById(req);
|
const monitor = await this.db.getHardwareDetailsById(req);
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
|
|||||||
@@ -232,6 +232,14 @@ const getMonitorURLByQueryValidation = joi.object({
|
|||||||
monitorURL: joi.string().uri().required(),
|
monitorURL: joi.string().uri().required(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getHardwareDetailsByIdParamValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const getHardwareDetailsByIdQueryValidation = joi.object({
|
||||||
|
dateRange: joi.string().valid("day", "week", "month"),
|
||||||
|
});
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// Alerts
|
// Alerts
|
||||||
//****************************************
|
//****************************************
|
||||||
@@ -465,6 +473,8 @@ export {
|
|||||||
getMonitorsByTeamIdQueryValidation,
|
getMonitorsByTeamIdQueryValidation,
|
||||||
getMonitorStatsByIdParamValidation,
|
getMonitorStatsByIdParamValidation,
|
||||||
getMonitorStatsByIdQueryValidation,
|
getMonitorStatsByIdQueryValidation,
|
||||||
|
getHardwareDetailsByIdParamValidation,
|
||||||
|
getHardwareDetailsByIdQueryValidation,
|
||||||
getCertificateParamValidation,
|
getCertificateParamValidation,
|
||||||
editMonitorBodyValidation,
|
editMonitorBodyValidation,
|
||||||
pauseMonitorParamValidation,
|
pauseMonitorParamValidation,
|
||||||
|
|||||||
Reference in new issue
Block a user