Adapting Express.js
Now, it actually is possible to recreate some of this behavior with Express.js using a set of middleware. The express - async - handler npm module provides a wrapper function that can interpose and allow a async controller function to interact nicely with the Express.js app . use API. Unfortunately, this requires the developer to manually wrap each controller function: const asyncHandler = require ( 'express-async-handler' ) app . post ( '/user' , asyncHandler ( async ( req , res , next ) => { const bar = await foo . findAll (); res . send ( bar ); })) The response tuple unwrapping can also be handled by middleware. Such a middleware would need to run after the controller code has run and would replace the array with a representation Express.js is expecting. The ability to promise the request body stream parsing can also be built in a generic manner: app . use ( ( req , res , next ) => { req . bodyToJson = requ...