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
await routes in express. This npm module allows you to use this solution in the typescript sources.
# With npm npm install --save async-wrapper-express-ts # With yarn yarn add async-wrapper-express-ts
import asyncWrapper from 'asyncWrapper' ... app.get('/foo', asyncWrapper(someAsyncRouteFunction))