overjoy-await
v0.0.5
Published
Hapi.js plugin to provide handler works nicely with async/await function
Downloads
9
Maintainers
Readme
overjoy-await
ES7 async/await route handler plugin for hapi.js.
How to use
Register plugin
const Hapi = require('hapi');
const server = new Hapi.Server();
server.register({
register: require('overjoy-await')
});
Options
handlerName
- hapi handler name for plugin. Default toawait
.
Add server route handler (simple)
server.route({
method: 'GET',
path: '/sample',
handler: {
async await(req) {
const result1 = await doSomethingAsync();
const result2 = doSomethingMore(result1);
const result3 = await continueWithSomethingAsync(result2);
return result3
}
}
});
For more usages, please take a look at test directory.