Skip to content

vietthang/overjoy-await

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

overjoy-await

ES7 async/await route handler plugin for hapi.js.

NPM

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 to await.

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.

About

ES7 async/await route handler plugin for hapi.js.

Resources

License

Stars

Watchers

Forks

Packages

No packages published