catch-async-express
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Async callback controllers

Example

When the function you write you do not know how to catch the error.

createUser = async (req: Request, res: Response) => {
    const user = await userService.createUser(req.body);
    res.status(httpStatus.CREATED).send(user);
  };

Install

  • with npm
npm install catch-async-express 
  • with yarn
yarn add catch-async-express 

Use

Help catch any error if it happens
createUser = catchAsync(async (req: Request, res: Response) => {
    const user = await this.userService.createUser(req.body);
    res.status(httpStatus.CREATED).send(user);
  });

Package Sidebar

Install

npm i catch-async-express

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

1.73 kB

Total Files

4

Last publish

Collaborators

  • hoanman1108