Async / Await IIFE in Hapi 17 Routing


The hapi 17 release is a complete (non-backwards compatible) rewrite of the popular enterprise-grade Node framework. Most notably it introduces async / await end-to-end.

In one of our applications we need to fetch data from a different API on incoming requests. Here is how I implemented the routing by returning an immediately-invoked async / await function expression: