This seems like a straightforward google, but I can\'t seem to find the answer...
Can you pass in ES7 async functions to the Express router?
Example:
<
While it seems to work, it stops handling errors thrown inside the async function, and as a result, if an error is not handled, the server never responds and the client keeps waiting until it timeout.
The correct behavior should be to respond with a 500 status code.
const router = require('express-promise-router')();
// Use it like a normal router, it will handle async functions
const asyncify = require('express-asyncify')
app
objectReplace var app = express();
with
var app = asyncify(express());
router
objectsReplace var router = express.Router();
with
var router = asyncify(express.Router());
You only need to apply the asyncify
function in the objects where you set the routes directly
https://www.npmjs.com/package/express-asyncify