Skip to content

express-async-middleware-wrapper 2.2.0

Install from the command line:
Learn more about npm packages
$ npm install @myrotvorets/express-async-middleware-wrapper@2.2.0
Install via package.json:
"@myrotvorets/express-async-middleware-wrapper": "2.2.0"

About this version

express-async-middleware-wrapper

Quality Gate Status Build and Test CI codebeat badge

Wrapper for Express.js async middleware to handle rejected promises and synchronous exceptions.

This library is similar to express-async-handler but is written in TypeScript, and its typings handle more cases than those of express-async-handler (for example, it can deal with the changes introduced in DefinitelyTyped/DefinitelyTyped#49677)

Usage

import { Request, Response, Router } from 'express';
import wrapper from '@myrotvorets/express-async-middleware-wrapper';

async function handler(req: Request, res: Response): Promise<void> {
    const someAsyncResult = await someAsyncAction();
    res.json(someAsyncResult);
}

const router = Router();
router.get('/some-path', wrapper(handler));

What it Does

It provides error handling for asynchronous middleware by catching rejected promises and synchronous exceptions from handler's code.

This wrapper simplfies development by eliminating the need to write boilerplate code for asynchronous handlers.

Details


Assets

  • express-async-middleware-wrapper-2.2.0.tgz

Download activity

  • Total downloads 31,186
  • Last 30 days 0
  • Last week 0
  • Today 0