// Wraps an async route handler so thrown errors flow to Express's error middleware // instead of becoming unhandled rejections. module.exports = function asyncHandler(fn) { return (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next); };