2.2.0 • Published 7 months ago

@myrotvorets/express-async-middleware-wrapper v2.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 months ago

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.

2.2.0

7 months ago

2.1.0

1 year ago

2.0.10

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago