Route Update All Monitor/Team Checks
This commit is contained in:
1 parent
e8908351a2
commit
a9c1d131a5
4 files changed
+68
No files matched your search
@@ -9,6 +9,8 @@ import {
|
||||
deleteChecksByTeamIdParamValidation,
|
||||
updateChecksTTLBodyValidation,
|
||||
updateCheckStatusBodyValidation,
|
||||
updateAllChecksStatusBodyValidation,
|
||||
updateCheckStatusParamValidation,
|
||||
} from "../validation/joi.js";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { getTokenFromHeaders } from "../utils/utils.js";
|
||||
@@ -130,6 +132,34 @@ class CheckController {
|
||||
}
|
||||
};
|
||||
|
||||
updateAllChecksStatus = async (req, res, next) => {
|
||||
try {
|
||||
await updateCheckStatusParamValidation.validateAsync(req.params);
|
||||
await updateAllChecksStatusBodyValidation.validateAsync(req.body);
|
||||
} catch (error) {
|
||||
next(handleValidationError(error, SERVICE_NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { monitorId, teamId, target } = req.params;
|
||||
const { status } = req.body;
|
||||
|
||||
const updatedChecks = await this.db.updateAllChecksStatus(
|
||||
target === "monitor" ? monitorId : teamId,
|
||||
status,
|
||||
target
|
||||
);
|
||||
|
||||
return res.success({
|
||||
msg: this.stringService.checkUpdateStatus,
|
||||
data: updatedChecks,
|
||||
});
|
||||
} catch (error) {
|
||||
next(handleError(error, SERVICE_NAME, "updateAllChecksStatus"));
|
||||
}
|
||||
};
|
||||
|
||||
deleteChecks = async (req, res, next) => {
|
||||
try {
|
||||
await deleteChecksParamValidation.validateAsync(req.params);
|
||||
|
||||
Reference in new issue
Block a user