Merge pull request #788 from bluewave-labs/fix/missing-be-validation
Fix/missing be validation
This commit is contained in:
2 files changed
+26
-2
No files matched your search
@@ -6,6 +6,9 @@ const {
|
|||||||
editMonitorBodyValidation,
|
editMonitorBodyValidation,
|
||||||
getMonitorsByTeamIdQueryValidation,
|
getMonitorsByTeamIdQueryValidation,
|
||||||
pauseMonitorParamValidation,
|
pauseMonitorParamValidation,
|
||||||
|
getMonitorStatsByIdParamValidation,
|
||||||
|
getMonitorStatsByIdQueryValidation,
|
||||||
|
getCertificateParamValidation,
|
||||||
getMonitorAggregateStatsParamValidation,
|
getMonitorAggregateStatsParamValidation,
|
||||||
getMonitorAggregateStatsQueryValidation,
|
getMonitorAggregateStatsQueryValidation,
|
||||||
} = require("../validation/joi");
|
} = require("../validation/joi");
|
||||||
@@ -84,7 +87,8 @@ const getMonitorAggregateStats = 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 getMonitorStatsByIdQueryValidation.validateAsync(req.query);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.message =
|
error.message =
|
||||||
@@ -108,7 +112,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 =
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const joi = require("joi");
|
const joi = require("joi");
|
||||||
|
const { normalize } = require("path");
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// Custom Validators
|
// Custom Validators
|
||||||
@@ -177,6 +178,22 @@ const getMonitorsByTeamIdQueryValidation = joi.object({
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getMonitorStatsByIdParamValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
});
|
||||||
|
const getMonitorStatsByIdQueryValidation = joi.object({
|
||||||
|
status: joi.string(),
|
||||||
|
limit: joi.number(),
|
||||||
|
sortOrder: joi.string().valid("asc", "desc"),
|
||||||
|
dateRange: joi.string().valid("day", "week", "month"),
|
||||||
|
numToDisplay: joi.number(),
|
||||||
|
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(),
|
||||||
@@ -364,6 +381,9 @@ module.exports = {
|
|||||||
getMonitorByIdQueryValidation,
|
getMonitorByIdQueryValidation,
|
||||||
getMonitorsByTeamIdValidation,
|
getMonitorsByTeamIdValidation,
|
||||||
getMonitorsByTeamIdQueryValidation,
|
getMonitorsByTeamIdQueryValidation,
|
||||||
|
getMonitorStatsByIdParamValidation,
|
||||||
|
getMonitorStatsByIdQueryValidation,
|
||||||
|
getCertificateParamValidation,
|
||||||
getMonitorAggregateStatsParamValidation,
|
getMonitorAggregateStatsParamValidation,
|
||||||
getMonitorAggregateStatsQueryValidation,
|
getMonitorAggregateStatsQueryValidation,
|
||||||
editMonitorBodyValidation,
|
editMonitorBodyValidation,
|
||||||
|
|||||||
Reference in new issue
Block a user