Refactor getMonitorCertificate to remove redundant check, move invalid cert handling to FE
This commit is contained in:
1 parent
fb0ead89b7
commit
3f4678f5e6
1 file changed
+2
-9
@@ -86,7 +86,7 @@ const getMonitorCertificate = async (req, res, next, fetchMonitorCertificate) =>
|
|||||||
const { monitorId } = req.params;
|
const { monitorId } = req.params;
|
||||||
const monitor = await req.db.getMonitorById(monitorId);
|
const monitor = await req.db.getMonitorById(monitorId);
|
||||||
const certificate = await fetchMonitorCertificate(sslChecker, monitor);
|
const certificate = await fetchMonitorCertificate(sslChecker, monitor);
|
||||||
if (certificate && certificate.validTo) {
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_CERTIFICATE,
|
msg: successMessages.MONITOR_CERTIFICATE,
|
||||||
@@ -94,13 +94,6 @@ const getMonitorCertificate = async (req, res, next, fetchMonitorCertificate) =>
|
|||||||
certificateDate: new Date(certificate.validTo),
|
certificateDate: new Date(certificate.validTo),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return res.status(200).json({
|
|
||||||
success: true,
|
|
||||||
msg: successMessages.MONITOR_CERTIFICATE,
|
|
||||||
data: { certificateDate: "N/A" },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(handleError(error, SERVICE_NAME, "getMonitorCertificate"));
|
next(handleError(error, SERVICE_NAME, "getMonitorCertificate"));
|
||||||
}
|
}
|
||||||
@@ -295,7 +288,7 @@ const checkEndpointResolution = async (req, res, next) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(handleError(error, SERVICE_NAME, "checkEndpointResolution"));
|
next(handleError(error, SERVICE_NAME, "checkEndpointResolution"));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a monitor by its ID and also deletes associated checks, alerts, and notifications.
|
* Deletes a monitor by its ID and also deletes associated checks, alerts, and notifications.
|
||||||
|
|||||||
Reference in new issue
Block a user