1.2.0 • Published 4 years ago

express-async-handler v1.2.0

Weekly downloads
82,822
License
MIT
Repository
github
Last release
4 years ago

Simple middleware for handling exceptions inside of async express routes and passing them to your express error handlers.

Installation:

npm install --save express-async-handler

or

yarn add express-async-handler

Usage:

const asyncHandler = require('express-async-handler')

express.get('/', asyncHandler(async (req, res, next) => {
	const bar = await foo.findAll();
	res.send(bar)
}))

Without express-async-handler

express.get('/',(req, res, next) => {
    foo.findAll()
    .then ( bar => {
       res.send(bar)
     } )
    .catch(next); // error passed on to the error handling route
})

Import in Typescript:

import asyncHandler from "express-async-handler"
demo_create_mern_appnode-scaffoldingpapiea-enginepapiea-sdkelixir-health-serverworks-api-reportexpress-typescript-templaterest-smtp-sinkoicmanager@infinitebrahmanuniverse/nolb-express-a@statstic/gb2260@everything-registry/sub-chunk-1631gb2260-xrr_backend_common@viy-ui/preview-serverstaart-managerstarter-e3starter-mern-backend-packstrapi-ethwallet-custom-field@companieshouse/node-session-handler@companieshouse/web-security-node@digitalbazaar/webkms-switch@data-proxy/server@dendronhq/api-server@prairielearn/sessionkarinasjsmetabackendlatest-mycontact-backendqurba-node-commononeusoxygen-xnow-and-wowsuanpan_node_sdkst-authst-auth-typescriptstark-dbtypescript-webhook-exampleusers-serviceutils-serviceutils_token_cesi_package@as-ticket/common@andes/api-tool@associ/orgs@associ/users@associ/users-db@aldea/mocknet@alancnet/material-framework@backplane-software/backplane-api@backplane-software/backplane-aws@backplane-software/backplane-azure@backplane-software/backplane-gcp@affixapi/integrator@blossm/authentication-middleware@blossm/authorization-middleware@blossm/server@carolina.js/auth@brightspot/styleguide@caytu/common@0x/coordinator-server@0x/quote-server@3merge/express-auth-middleware@3merge/express-starter@axenuab/joymon-admin-user-portal-backend@dbrowser/tracker@digitalbazaar/ezcap-expresswarframe-statuswarehouse.ai-status-apiwebkms-switch@igloo-amaging-platform/server@friggframework/core@estonsuli/aplikasi-kp@func1/common@func1/common1@koreanwglasses/commons-beta@koreanwglasses/commons-nexs-server@koreanwglasses/restate@local-ads/express@logzio-node-toolbox/server@natour/common@nobbas/rest-router@entwico/spa-resort@echelon-solutions/aws-event-sourcing@mindha-us/penguinserver@minisode/gb2260@mephisto5558/bot-website@mongozest/resource@moneybutton/express-paymail@internxt/cli@juanibiapina/wire@kevinejohn/express-paymail@razee/razeedash-api@react-admin-git-provider/dev-server@pxeeio/express-async-controller@ryus08/penguinserver@proshop/common@samislam/permissions@samislam/switcher@satellite-earth/core@reactive-video/builder@openintegrationhub/webhooks
1.2.0

4 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago