lexguard-backend / src /utils /asyncHandler.js
github-actions[bot]
Deploy to Hugging Face
b921752
Raw
History Blame Contribute Delete
273 Bytes
/**
* Wraps async Express route handlers to automatically catch errors
* and forward them to the global error handler via next().
*/
const asyncHandler = (fn) => (req, res, next) => {
Promise.resolve(fn(req, res, next)).catch(next);
};
module.exports = asyncHandler;