Note: This library is no longer needed since hapi17. This feature has been included as standard since hapi 17. You can use this plugin up to version 16 hapijs.
See the link below.
async handler support for hapijs apps
You can use this plugin to add async handler function to your hapi projects.
You need es7 supported javascript development environment or use Typescript
Example:
const server = new Hapi.server()
const plugins = [
...
{
register: require('hapi-es7-async-handler'),
},
...
];
server.register(plugins, (err) => {
...
})
server.route({
path: '/',
method: 'get',
handler: async (request, reply) => {
...
const result = await yourAsyncJob(); // the async job might be returning Promise object
reply(result);
}
});