Add validation for certificate request
This commit is contained in:
1 parent
cece932e45
commit
8bac81fb09
2 files changed
+9
-5
No files matched your search
@@ -8,12 +8,12 @@ const {
|
|||||||
pauseMonitorParamValidation,
|
pauseMonitorParamValidation,
|
||||||
getMonitorStatsByIdParamValidation,
|
getMonitorStatsByIdParamValidation,
|
||||||
getMonitorStatsByIdQueryValidation,
|
getMonitorStatsByIdQueryValidation,
|
||||||
|
getCertificateParamValidation,
|
||||||
} = require("../validation/joi");
|
} = require("../validation/joi");
|
||||||
|
|
||||||
const sslChecker = require("ssl-checker");
|
const sslChecker = require("ssl-checker");
|
||||||
const SERVICE_NAME = "monitorController";
|
const SERVICE_NAME = "monitorController";
|
||||||
const { errorMessages, successMessages } = require("../utils/messages");
|
const { errorMessages, successMessages } = require("../utils/messages");
|
||||||
const { runInNewContext } = require("vm");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all monitors
|
* Returns all monitors
|
||||||
@@ -47,7 +47,6 @@ const getAllMonitors = async (req, res, next) => {
|
|||||||
*/
|
*/
|
||||||
const getMonitorStatsById = async (req, res, next) => {
|
const getMonitorStatsById = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
//Validation
|
|
||||||
await getMonitorStatsByIdParamValidation.validateAsync(req.params);
|
await getMonitorStatsByIdParamValidation.validateAsync(req.params);
|
||||||
await getMonitorStatsByIdQueryValidation.validateAsync(req.query);
|
await getMonitorStatsByIdQueryValidation.validateAsync(req.query);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -73,7 +72,7 @@ const getMonitorStatsById = async (req, res, next) => {
|
|||||||
|
|
||||||
const getMonitorCertificate = async (req, res, next) => {
|
const getMonitorCertificate = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
//validation
|
await getCertificateParamValidation.validateAsync(req.params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.message =
|
error.message =
|
||||||
|
|||||||
@@ -178,10 +178,10 @@ const getMonitorsByTeamIdQueryValidation = joi.object({
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
getMonitorStatsByIdParamValidation = joi.object({
|
const getMonitorStatsByIdParamValidation = joi.object({
|
||||||
monitorId: joi.string().required(),
|
monitorId: joi.string().required(),
|
||||||
});
|
});
|
||||||
getMonitorStatsByIdQueryValidation = joi.object({
|
const getMonitorStatsByIdQueryValidation = joi.object({
|
||||||
status: joi.string(),
|
status: joi.string(),
|
||||||
limit: joi.number(),
|
limit: joi.number(),
|
||||||
sortOrder: joi.string().valid("asc", "desc"),
|
sortOrder: joi.string().valid("asc", "desc"),
|
||||||
@@ -190,6 +190,10 @@ getMonitorStatsByIdQueryValidation = joi.object({
|
|||||||
normalize: joi.boolean(),
|
normalize: joi.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getCertificateParamValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
const createMonitorBodyValidation = joi.object({
|
const createMonitorBodyValidation = joi.object({
|
||||||
_id: joi.string(),
|
_id: joi.string(),
|
||||||
userId: joi.string().required(),
|
userId: joi.string().required(),
|
||||||
@@ -372,6 +376,7 @@ module.exports = {
|
|||||||
getMonitorsByTeamIdQueryValidation,
|
getMonitorsByTeamIdQueryValidation,
|
||||||
getMonitorStatsByIdParamValidation,
|
getMonitorStatsByIdParamValidation,
|
||||||
getMonitorStatsByIdQueryValidation,
|
getMonitorStatsByIdQueryValidation,
|
||||||
|
getCertificateParamValidation,
|
||||||
editMonitorBodyValidation,
|
editMonitorBodyValidation,
|
||||||
pauseMonitorParamValidation,
|
pauseMonitorParamValidation,
|
||||||
editUserParamValidation,
|
editUserParamValidation,
|
||||||
|
|||||||
Reference in new issue
Block a user