async-wrapper-express-ts
v3.1.6
Published
A simple function for Typescript sources to wrap async Express route
Downloads
555
Readme
async-wrapper-express-ts
A simple function for Typescript sources to wrap async Express route
Wraps the express route in a function that passes the next
method from the route to the promise's catch statement which allows the middleware to catch the exception.
This code was borrowed from the StrongLoop blog post on handling async
/await
routes in express. This npm module allows you to use this solution in the typescript sources.
Install
# With npm
npm install --save async-wrapper-express-ts
# With yarn
yarn add async-wrapper-express-ts
Usage
import asyncWrapper from 'asyncWrapper'
...
app.get('/foo', asyncWrapper(someAsyncRouteFunction))