2024-10-15 11:57:37 +08:00
|
|
|
import joi from "joi";
|
2024-05-09 17:06:00 -04:00
|
|
|
|
2024-07-19 13:05:38 -07:00
|
|
|
//****************************************
|
|
|
|
|
// Custom Validators
|
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
|
|
const roleValidatior = (role) => (value, helpers) => {
|
2024-10-17 12:07:30 +08:00
|
|
|
const hasRole = role.some((role) => value.includes(role));
|
|
|
|
|
if (!hasRole) {
|
|
|
|
|
throw new joi.ValidationError(
|
|
|
|
|
`You do not have the required authorization. Required roles: ${role.join(", ")}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return value;
|
2024-07-19 13:05:38 -07:00
|
|
|
};
|
|
|
|
|
|
2024-05-29 10:59:29 -07:00
|
|
|
//****************************************
|
|
|
|
|
// Auth
|
|
|
|
|
//****************************************
|
|
|
|
|
|
2024-10-31 11:46:52 -04:00
|
|
|
const passwordPattern =
|
|
|
|
|
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!?@#$%^&*()\-_=+[\]{};:'",.<>~`|\\/])[A-Za-z0-9!?@#$%^&*()\-_=+[\]{};:'",.<>~`|\\/]+$/;
|
|
|
|
|
|
2024-05-14 23:15:29 -04:00
|
|
|
const loginValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
email: joi
|
|
|
|
|
.string()
|
|
|
|
|
.email()
|
|
|
|
|
.required()
|
|
|
|
|
.custom((value, helpers) => {
|
|
|
|
|
const lowercasedValue = value.toLowerCase();
|
|
|
|
|
if (value !== lowercasedValue) {
|
|
|
|
|
return helpers.message("Email must be in lowercase");
|
|
|
|
|
}
|
|
|
|
|
return lowercasedValue;
|
|
|
|
|
}),
|
2024-10-31 11:46:52 -04:00
|
|
|
password: joi.string().min(8).required().pattern(passwordPattern),
|
2024-05-14 23:15:29 -04:00
|
|
|
});
|
2024-06-07 11:19:32 -07:00
|
|
|
|
2024-08-26 17:43:56 -07:00
|
|
|
const registrationBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
firstName: joi
|
|
|
|
|
.string()
|
|
|
|
|
.required()
|
|
|
|
|
.pattern(/^[A-Za-z]+$/),
|
|
|
|
|
lastName: joi
|
|
|
|
|
.string()
|
|
|
|
|
.required()
|
|
|
|
|
.pattern(/^[A-Za-z]+$/),
|
|
|
|
|
email: joi
|
|
|
|
|
.string()
|
|
|
|
|
.email()
|
|
|
|
|
.required()
|
|
|
|
|
.custom((value, helpers) => {
|
|
|
|
|
const lowercasedValue = value.toLowerCase();
|
|
|
|
|
if (value !== lowercasedValue) {
|
|
|
|
|
return helpers.message("Email must be in lowercase");
|
|
|
|
|
}
|
|
|
|
|
return lowercasedValue;
|
|
|
|
|
}),
|
2024-10-31 11:46:52 -04:00
|
|
|
password: joi.string().min(8).required().pattern(passwordPattern),
|
2024-10-17 12:07:30 +08:00
|
|
|
profileImage: joi.any(),
|
|
|
|
|
role: joi
|
|
|
|
|
.array()
|
|
|
|
|
.items(joi.string().valid("superadmin", "admin", "user", "demo"))
|
|
|
|
|
.min(1)
|
|
|
|
|
.required(),
|
|
|
|
|
teamId: joi.string().allow("").required(),
|
|
|
|
|
inviteToken: joi.string().allow("").required(),
|
2024-05-09 17:06:00 -04:00
|
|
|
});
|
|
|
|
|
|
2024-05-29 10:59:29 -07:00
|
|
|
const editUserParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
userId: joi.string().required(),
|
2024-05-29 10:59:29 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const editUserBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
firstName: joi.string().pattern(/^[A-Za-z]+$/),
|
|
|
|
|
lastName: joi.string().pattern(/^[A-Za-z]+$/),
|
|
|
|
|
profileImage: joi.any(),
|
2024-10-31 11:46:52 -04:00
|
|
|
newPassword: joi.string().min(8).pattern(passwordPattern),
|
|
|
|
|
password: joi.string().min(8).pattern(passwordPattern),
|
2024-10-17 12:07:30 +08:00
|
|
|
deleteProfileImage: joi.boolean(),
|
|
|
|
|
role: joi.array(),
|
2024-05-29 10:59:29 -07:00
|
|
|
});
|
|
|
|
|
|
2024-06-11 14:46:39 -07:00
|
|
|
const recoveryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
email: joi
|
|
|
|
|
.string()
|
|
|
|
|
.email({ tlds: { allow: false } })
|
|
|
|
|
.required(),
|
2024-06-11 14:46:39 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const recoveryTokenValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
recoveryToken: joi.string().required(),
|
2024-06-11 14:46:39 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const newPasswordValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
recoveryToken: joi.string().required(),
|
2024-10-31 11:46:52 -04:00
|
|
|
password: joi.string().min(8).required().pattern(passwordPattern),
|
2024-10-17 12:07:30 +08:00
|
|
|
confirm: joi.string(),
|
2024-06-11 14:46:39 -07:00
|
|
|
});
|
|
|
|
|
|
2024-07-02 12:16:33 +03:30
|
|
|
const deleteUserParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
email: joi.string().email().required(),
|
2024-06-28 20:13:07 +03:30
|
|
|
});
|
|
|
|
|
|
2024-07-19 13:05:38 -07:00
|
|
|
const inviteRoleValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
roles: joi.custom(roleValidatior(["admin", "superadmin"])).required(),
|
2024-07-19 13:05:38 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const inviteBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
email: joi.string().trim().email().required().messages({
|
|
|
|
|
"string.empty": "Email is required",
|
|
|
|
|
"string.email": "Must be a valid email address",
|
|
|
|
|
}),
|
|
|
|
|
role: joi.array().required(),
|
|
|
|
|
teamId: joi.string().required(),
|
2024-07-19 13:05:38 -07:00
|
|
|
});
|
|
|
|
|
|
2024-10-15 11:57:37 +08:00
|
|
|
const inviteVerificationBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
token: joi.string().required(),
|
2024-07-23 12:27:23 -07:00
|
|
|
});
|
|
|
|
|
|
2024-05-29 10:59:29 -07:00
|
|
|
//****************************************
|
|
|
|
|
// Monitors
|
|
|
|
|
//****************************************
|
|
|
|
|
|
2024-07-26 18:56:39 -07:00
|
|
|
const getMonitorByIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-05-10 13:36:04 -07:00
|
|
|
});
|
2024-05-09 17:06:00 -04:00
|
|
|
|
2024-07-26 18:56:39 -07:00
|
|
|
const getMonitorByIdQueryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
status: joi.boolean(),
|
|
|
|
|
sortOrder: joi.string().valid("asc", "desc"),
|
|
|
|
|
limit: joi.number(),
|
2025-01-22 11:07:43 -08:00
|
|
|
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
2024-10-17 12:07:30 +08:00
|
|
|
numToDisplay: joi.number(),
|
|
|
|
|
normalize: joi.boolean(),
|
2024-07-26 18:56:39 -07:00
|
|
|
});
|
|
|
|
|
|
2025-01-08 13:42:43 -08:00
|
|
|
const getMonitorsByTeamIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
teamId: joi.string().required(),
|
2024-05-10 13:59:33 -07:00
|
|
|
});
|
|
|
|
|
|
2024-08-26 19:38:24 -07:00
|
|
|
const getMonitorsByTeamIdQueryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
limit: joi.number(),
|
|
|
|
|
type: joi
|
|
|
|
|
.alternatives()
|
|
|
|
|
.try(
|
2024-12-27 11:16:09 -08:00
|
|
|
joi.string().valid("http", "ping", "pagespeed", "docker", "hardware", "port"),
|
2024-11-26 22:28:00 +08:00
|
|
|
joi
|
|
|
|
|
.array()
|
2024-12-27 11:16:09 -08:00
|
|
|
.items(
|
|
|
|
|
joi.string().valid("http", "ping", "pagespeed", "docker", "hardware", "port")
|
|
|
|
|
)
|
2024-10-17 12:07:30 +08:00
|
|
|
),
|
|
|
|
|
page: joi.number(),
|
|
|
|
|
rowsPerPage: joi.number(),
|
|
|
|
|
filter: joi.string(),
|
|
|
|
|
field: joi.string(),
|
|
|
|
|
order: joi.string().valid("asc", "desc"),
|
2024-07-26 18:56:39 -07:00
|
|
|
});
|
|
|
|
|
|
2024-09-03 15:11:17 -07:00
|
|
|
const getMonitorStatsByIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-09-03 15:00:30 -07:00
|
|
|
});
|
2024-09-03 15:11:17 -07:00
|
|
|
const getMonitorStatsByIdQueryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
status: joi.string(),
|
|
|
|
|
limit: joi.number(),
|
|
|
|
|
sortOrder: joi.string().valid("asc", "desc"),
|
2025-01-22 11:07:43 -08:00
|
|
|
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
2024-10-17 12:07:30 +08:00
|
|
|
numToDisplay: joi.number(),
|
|
|
|
|
normalize: joi.boolean(),
|
2024-09-03 15:00:30 -07:00
|
|
|
});
|
|
|
|
|
|
2024-09-03 15:11:17 -07:00
|
|
|
const getCertificateParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-09-03 15:11:17 -07:00
|
|
|
});
|
|
|
|
|
|
2024-07-31 12:12:05 -07:00
|
|
|
const createMonitorBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
_id: joi.string(),
|
|
|
|
|
userId: joi.string().required(),
|
|
|
|
|
teamId: joi.string().required(),
|
|
|
|
|
name: joi.string().required(),
|
|
|
|
|
description: joi.string().required(),
|
|
|
|
|
type: joi.string().required(),
|
|
|
|
|
url: joi.string().required(),
|
2024-12-27 10:49:54 -08:00
|
|
|
port: joi.number(),
|
2024-10-17 12:07:30 +08:00
|
|
|
isActive: joi.boolean(),
|
|
|
|
|
interval: joi.number(),
|
2024-10-23 12:06:05 +08:00
|
|
|
thresholds: joi.object().keys({
|
|
|
|
|
usage_cpu: joi.number(),
|
|
|
|
|
usage_memory: joi.number(),
|
|
|
|
|
usage_disk: joi.number(),
|
2024-11-25 11:20:52 +08:00
|
|
|
usage_temperature: joi.number(),
|
2024-10-23 12:06:05 +08:00
|
|
|
}),
|
2024-10-17 12:07:30 +08:00
|
|
|
notifications: joi.array().items(joi.object()),
|
2024-10-29 13:51:50 +08:00
|
|
|
secret: joi.string(),
|
2024-05-21 11:23:39 -07:00
|
|
|
});
|
|
|
|
|
|
2024-07-24 12:08:42 -07:00
|
|
|
const editMonitorBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
name: joi.string(),
|
|
|
|
|
description: joi.string(),
|
|
|
|
|
interval: joi.number(),
|
|
|
|
|
notifications: joi.array().items(joi.object()),
|
2024-10-29 13:51:50 +08:00
|
|
|
secret: joi.string(),
|
2024-07-24 12:08:42 -07:00
|
|
|
});
|
|
|
|
|
|
2024-08-28 15:21:59 -07:00
|
|
|
const pauseMonitorParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-08-28 15:21:59 -07:00
|
|
|
});
|
|
|
|
|
|
2024-10-17 12:35:15 +05:30
|
|
|
const getMonitorURLByQueryValidation = joi.object({
|
2024-10-18 11:39:07 +05:30
|
|
|
monitorURL: joi.string().uri().required(),
|
2024-10-17 12:35:15 +05:30
|
|
|
});
|
|
|
|
|
|
2025-01-01 09:08:07 -08:00
|
|
|
const getHardwareDetailsByIdParamValidation = joi.object({
|
|
|
|
|
monitorId: joi.string().required(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getHardwareDetailsByIdQueryValidation = joi.object({
|
2025-01-22 11:07:43 -08:00
|
|
|
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
2025-01-01 09:08:07 -08:00
|
|
|
});
|
|
|
|
|
|
2024-05-29 10:59:29 -07:00
|
|
|
//****************************************
|
|
|
|
|
// Alerts
|
|
|
|
|
//****************************************
|
2024-05-27 11:57:25 -07:00
|
|
|
|
2024-05-28 11:39:55 -07:00
|
|
|
const createAlertParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-05-28 11:39:55 -07:00
|
|
|
});
|
|
|
|
|
|
2024-05-28 13:02:19 -07:00
|
|
|
const createAlertBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
checkId: joi.string().required(),
|
|
|
|
|
monitorId: joi.string().required(),
|
|
|
|
|
userId: joi.string().required(),
|
|
|
|
|
status: joi.boolean(),
|
|
|
|
|
message: joi.string(),
|
|
|
|
|
notifiedStatus: joi.boolean(),
|
|
|
|
|
acknowledgeStatus: joi.boolean(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getAlertsByUserIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
userId: joi.string().required(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getAlertsByMonitorIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getAlertByIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
alertId: joi.string().required(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const editAlertParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
alertId: joi.string().required(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const editAlertBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
status: joi.boolean(),
|
|
|
|
|
message: joi.string(),
|
|
|
|
|
notifiedStatus: joi.boolean(),
|
|
|
|
|
acknowledgeStatus: joi.boolean(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const deleteAlertParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
alertId: joi.string().required(),
|
2024-05-28 13:02:19 -07:00
|
|
|
});
|
|
|
|
|
|
2024-05-29 10:59:29 -07:00
|
|
|
//****************************************
|
|
|
|
|
// Checks
|
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
|
|
const createCheckParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-05-29 10:59:29 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const createCheckBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
|
|
|
|
status: joi.boolean().required(),
|
|
|
|
|
responseTime: joi.number().required(),
|
|
|
|
|
statusCode: joi.number().required(),
|
|
|
|
|
message: joi.string().required(),
|
2024-05-29 10:59:29 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getChecksParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-05-29 10:59:29 -07:00
|
|
|
});
|
|
|
|
|
|
2024-08-08 12:37:02 -07:00
|
|
|
const getChecksQueryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
sortOrder: joi.string().valid("asc", "desc"),
|
|
|
|
|
limit: joi.number(),
|
2025-01-22 11:07:43 -08:00
|
|
|
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
2024-10-17 12:07:30 +08:00
|
|
|
filter: joi.string().valid("all", "down", "resolve"),
|
|
|
|
|
page: joi.number(),
|
|
|
|
|
rowsPerPage: joi.number(),
|
2024-08-08 12:37:02 -07:00
|
|
|
});
|
|
|
|
|
|
2024-08-27 12:22:32 -07:00
|
|
|
const getTeamChecksParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
teamId: joi.string().required(),
|
2024-08-09 11:54:30 -07:00
|
|
|
});
|
|
|
|
|
|
2024-08-27 12:22:32 -07:00
|
|
|
const getTeamChecksQueryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
sortOrder: joi.string().valid("asc", "desc"),
|
|
|
|
|
limit: joi.number(),
|
2025-01-22 11:07:43 -08:00
|
|
|
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
2024-10-17 12:07:30 +08:00
|
|
|
filter: joi.string().valid("all", "down", "resolve"),
|
|
|
|
|
page: joi.number(),
|
|
|
|
|
rowsPerPage: joi.number(),
|
2024-08-09 11:54:30 -07:00
|
|
|
});
|
|
|
|
|
|
2024-05-29 10:59:29 -07:00
|
|
|
const deleteChecksParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-05-29 10:59:29 -07:00
|
|
|
});
|
|
|
|
|
|
2024-08-30 10:04:47 -07:00
|
|
|
const deleteChecksByTeamIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
teamId: joi.string().required(),
|
2024-08-30 09:41:42 -07:00
|
|
|
});
|
|
|
|
|
|
2024-09-14 12:16:13 +08:00
|
|
|
const updateChecksTTLBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
ttl: joi.number().required(),
|
2024-09-14 12:16:13 +08:00
|
|
|
});
|
|
|
|
|
|
2024-07-17 15:09:46 -07:00
|
|
|
//****************************************
|
|
|
|
|
// PageSpeedCheckValidation
|
|
|
|
|
//****************************************
|
2024-07-19 12:46:11 -07:00
|
|
|
|
2024-07-17 15:19:27 -07:00
|
|
|
const getPageSpeedCheckParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-07-17 15:19:27 -07:00
|
|
|
});
|
|
|
|
|
|
2024-07-19 12:46:11 -07:00
|
|
|
//Validation schema for the monitorId parameter
|
2024-07-17 15:19:27 -07:00
|
|
|
const createPageSpeedCheckParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-07-19 12:46:11 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//Validation schema for the monitorId body
|
|
|
|
|
const createPageSpeedCheckBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
url: joi.string().required(),
|
2024-07-17 15:19:27 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const deletePageSpeedCheckParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-07-17 15:09:46 -07:00
|
|
|
});
|
|
|
|
|
|
2024-07-30 10:01:52 -07:00
|
|
|
//****************************************
|
|
|
|
|
// MaintenanceWindowValidation
|
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
|
|
const createMaintenanceWindowBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitors: joi.array().items(joi.string()).required(),
|
|
|
|
|
name: joi.string().required(),
|
|
|
|
|
active: joi.boolean(),
|
|
|
|
|
start: joi.date().required(),
|
|
|
|
|
end: joi.date().required(),
|
|
|
|
|
repeat: joi.number().required(),
|
|
|
|
|
expiry: joi.date(),
|
2024-07-30 10:01:52 -07:00
|
|
|
});
|
|
|
|
|
|
2024-10-09 12:06:01 +08:00
|
|
|
const getMaintenanceWindowByIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
id: joi.string().required(),
|
2024-10-09 12:06:01 +08:00
|
|
|
});
|
|
|
|
|
|
2024-10-04 13:49:53 +08:00
|
|
|
const getMaintenanceWindowsByTeamIdQueryValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
active: joi.boolean(),
|
|
|
|
|
page: joi.number(),
|
|
|
|
|
rowsPerPage: joi.number(),
|
|
|
|
|
field: joi.string(),
|
|
|
|
|
order: joi.string().valid("asc", "desc"),
|
2024-07-30 10:01:52 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getMaintenanceWindowsByMonitorIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
monitorId: joi.string().required(),
|
2024-07-30 10:01:52 -07:00
|
|
|
});
|
|
|
|
|
|
2024-10-09 11:07:14 +08:00
|
|
|
const deleteMaintenanceWindowByIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
id: joi.string().required(),
|
2024-10-09 11:07:14 +08:00
|
|
|
});
|
|
|
|
|
|
2024-10-09 11:33:12 +08:00
|
|
|
const editMaintenanceWindowByIdParamValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
id: joi.string().required(),
|
2024-10-09 11:33:12 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const editMaintenanceByIdWindowBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
active: joi.boolean(),
|
|
|
|
|
name: joi.string(),
|
|
|
|
|
repeat: joi.number(),
|
|
|
|
|
start: joi.date(),
|
|
|
|
|
end: joi.date(),
|
|
|
|
|
expiry: joi.date(),
|
|
|
|
|
monitors: joi.array(),
|
2024-10-09 11:33:12 +08:00
|
|
|
});
|
|
|
|
|
|
2024-09-26 14:37:11 +08:00
|
|
|
//****************************************
|
|
|
|
|
// SettingsValidation
|
|
|
|
|
//****************************************
|
|
|
|
|
const updateAppSettingsBodyValidation = joi.object({
|
2024-10-17 12:07:30 +08:00
|
|
|
apiBaseUrl: joi.string().allow(""),
|
|
|
|
|
logLevel: joi.string().valid("debug", "none", "error", "warn").allow(""),
|
|
|
|
|
clientHost: joi.string().allow(""),
|
|
|
|
|
dbType: joi.string().allow(""),
|
|
|
|
|
dbConnectionString: joi.string().allow(""),
|
|
|
|
|
redisHost: joi.string().allow(""),
|
|
|
|
|
redisPort: joi.number().allow(null, ""),
|
|
|
|
|
jwtTTL: joi.string().allow(""),
|
|
|
|
|
pagespeedApiKey: joi.string().allow(""),
|
|
|
|
|
systemEmailHost: joi.string().allow(""),
|
|
|
|
|
systemEmailPort: joi.number().allow(""),
|
|
|
|
|
systemEmailAddress: joi.string().allow(""),
|
|
|
|
|
systemEmailPassword: joi.string().allow(""),
|
2024-09-26 14:37:11 +08:00
|
|
|
});
|
|
|
|
|
|
2024-11-11 12:17:19 +08:00
|
|
|
//****************************************
|
|
|
|
|
// Status Page Validation
|
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
|
|
const getStatusPageParamValidation = joi.object({
|
|
|
|
|
url: joi.string().required(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const createStatusPageBodyValidation = joi.object({
|
|
|
|
|
companyName: joi.string().required(),
|
|
|
|
|
url: joi.string().required(),
|
|
|
|
|
timezone: joi.string().required(),
|
|
|
|
|
color: joi.string().required(),
|
|
|
|
|
theme: joi.string().required(),
|
|
|
|
|
monitors: joi
|
|
|
|
|
.array()
|
|
|
|
|
.items(joi.string().pattern(/^[0-9a-fA-F]{24}$/))
|
|
|
|
|
.required()
|
|
|
|
|
.messages({
|
|
|
|
|
"string.pattern.base": "Must be a valid monitor ID",
|
|
|
|
|
"array.base": "Monitors must be an array",
|
|
|
|
|
"array.empty": "At least one monitor is required",
|
|
|
|
|
"any.required": "Monitors are required",
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
2024-10-15 11:57:37 +08:00
|
|
|
export {
|
2024-10-17 12:07:30 +08:00
|
|
|
roleValidatior,
|
|
|
|
|
loginValidation,
|
|
|
|
|
registrationBodyValidation,
|
|
|
|
|
recoveryValidation,
|
|
|
|
|
recoveryTokenValidation,
|
|
|
|
|
newPasswordValidation,
|
|
|
|
|
inviteRoleValidation,
|
|
|
|
|
inviteBodyValidation,
|
|
|
|
|
inviteVerificationBodyValidation,
|
|
|
|
|
createMonitorBodyValidation,
|
|
|
|
|
getMonitorByIdParamValidation,
|
|
|
|
|
getMonitorByIdQueryValidation,
|
2025-01-08 13:42:43 -08:00
|
|
|
getMonitorsByTeamIdParamValidation,
|
2024-10-17 12:07:30 +08:00
|
|
|
getMonitorsByTeamIdQueryValidation,
|
|
|
|
|
getMonitorStatsByIdParamValidation,
|
|
|
|
|
getMonitorStatsByIdQueryValidation,
|
2025-01-01 09:08:07 -08:00
|
|
|
getHardwareDetailsByIdParamValidation,
|
|
|
|
|
getHardwareDetailsByIdQueryValidation,
|
2024-10-17 12:07:30 +08:00
|
|
|
getCertificateParamValidation,
|
|
|
|
|
editMonitorBodyValidation,
|
|
|
|
|
pauseMonitorParamValidation,
|
2024-10-18 11:39:07 +05:30
|
|
|
getMonitorURLByQueryValidation,
|
2024-10-17 12:07:30 +08:00
|
|
|
editUserParamValidation,
|
|
|
|
|
editUserBodyValidation,
|
|
|
|
|
createAlertParamValidation,
|
|
|
|
|
createAlertBodyValidation,
|
|
|
|
|
getAlertsByUserIdParamValidation,
|
|
|
|
|
getAlertsByMonitorIdParamValidation,
|
|
|
|
|
getAlertByIdParamValidation,
|
|
|
|
|
editAlertParamValidation,
|
|
|
|
|
editAlertBodyValidation,
|
|
|
|
|
deleteAlertParamValidation,
|
|
|
|
|
createCheckParamValidation,
|
|
|
|
|
createCheckBodyValidation,
|
|
|
|
|
getChecksParamValidation,
|
|
|
|
|
getChecksQueryValidation,
|
|
|
|
|
getTeamChecksParamValidation,
|
|
|
|
|
getTeamChecksQueryValidation,
|
|
|
|
|
deleteChecksParamValidation,
|
|
|
|
|
deleteChecksByTeamIdParamValidation,
|
|
|
|
|
updateChecksTTLBodyValidation,
|
|
|
|
|
deleteUserParamValidation,
|
|
|
|
|
getPageSpeedCheckParamValidation,
|
|
|
|
|
createPageSpeedCheckParamValidation,
|
|
|
|
|
deletePageSpeedCheckParamValidation,
|
|
|
|
|
createPageSpeedCheckBodyValidation,
|
|
|
|
|
createMaintenanceWindowBodyValidation,
|
|
|
|
|
getMaintenanceWindowByIdParamValidation,
|
|
|
|
|
getMaintenanceWindowsByTeamIdQueryValidation,
|
|
|
|
|
getMaintenanceWindowsByMonitorIdParamValidation,
|
|
|
|
|
deleteMaintenanceWindowByIdParamValidation,
|
|
|
|
|
editMaintenanceWindowByIdParamValidation,
|
|
|
|
|
editMaintenanceByIdWindowBodyValidation,
|
|
|
|
|
updateAppSettingsBodyValidation,
|
2024-11-11 12:17:19 +08:00
|
|
|
createStatusPageBodyValidation,
|
|
|
|
|
getStatusPageParamValidation,
|
2024-05-10 13:59:33 -07:00
|
|
|
};
|