UNPKG

create-express-quickstart

Version:

Create a Node.js app for building production-ready RESTful APIs using Express, by running one command

11 lines (9 loc) 362 B
/** * A higher-order function to handle asynchronous route handlers. * @param {Function} fn - The asynchronous function to handle. * @returns {Function} - A function that handles the request, response, and next middleware. */ const asyncHandler = (fn) => (req, res, next) => { Promise.resolve(fn(req, res, next)).catch(next) } export default asyncHandler