Skip to content

Commit

Permalink
Simplified exports
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcumplido committed Feb 4, 2023
1 parent a449d8d commit abd7058
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion middlewares/errorHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ function errorHandler(err, req, res, next) {
});
}

module.exports = { logErrors: logErrors, errorHandler: errorHandler };
module.exports = { logErrors, errorHandler };
12 changes: 12 additions & 0 deletions middlewares/validatorHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function validatorHandler(schema, property) {
return (req, res, next) => {
const data = req[property];
const { error } = schema.validate(data, { abortEarly: false });
if (error) {
next(error);
}
next();
};
}

module.exports = validatorHandler;

0 comments on commit abd7058

Please sign in to comment.