UNPKG

node-js-api-response-ts

Version:

Unified API response and error handling for Express.js in TypeScript. This package provides a middleware for consistent API responses and error handling in Express applications, making it easier to manage API responses and errors in a standardized way.

10 lines (9 loc) 290 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.asyncHandler = void 0; const asyncHandler = (fn) => { return (req, res, next) => { Promise.resolve(fn(req, res, next)).catch((err) => next(err)); }; }; exports.asyncHandler = asyncHandler;