|
@@ -1,22 +1,24 @@
|
|
|
-export function checkReqBody(schema) {
|
|
|
|
|
|
|
+export function checkReqBody(schema, log, route) {
|
|
|
return function checkValid(req, res, next) {
|
|
return function checkValid(req, res, next) {
|
|
|
- schema.isValid(req.body).then((valid) => {
|
|
|
|
|
|
|
+ schema.isValid(req.body).then(valid => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
next();
|
|
next();
|
|
|
} else {
|
|
} else {
|
|
|
res.send('Incorrect request');
|
|
res.send('Incorrect request');
|
|
|
|
|
+ log.debug(`Invalid request for route: ${route}, ${JSON.stringify(req.params)}`);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function checkParams(schema) {
|
|
|
|
|
|
|
+export function checkParams(schema, log, route) {
|
|
|
return function checkValid(req, res, next) {
|
|
return function checkValid(req, res, next) {
|
|
|
- schema.isValid(req.params).then((valid) => {
|
|
|
|
|
|
|
+ schema.isValid(req.params).then(valid => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
next();
|
|
next();
|
|
|
} else {
|
|
} else {
|
|
|
res.send('Incorrect request');
|
|
res.send('Incorrect request');
|
|
|
|
|
+ log.debug(`Invalid request for route: ${route}, ${JSON.stringify(req.params)}`);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|