| 12345678910111213141516171819202122232425 |
- export function checkReqBody(schema, log, path) {
- return function checkValid(req, res, next) {
- schema.isValid(req.body).then(valid => {
- if (valid) {
- next();
- } else {
- res.send(400, { error: 'Bad request' });
- log.debug(`Invalid request for route: ${path}, ${JSON.stringify(req.params)}`);
- }
- });
- };
- }
- export function checkParams(schema, log, path) {
- return function checkValid(req, res, next) {
- schema.isValid(req.params).then(valid => {
- if (valid) {
- next();
- } else {
- res.send(400, { error: 'Bad request' });
- log.debug(`Invalid request for route: ${path}, ${JSON.stringify(req.params)}`);
- }
- });
- };
- }
|