hapi-es7-async-handler

1.0.11 • Public • Published

hapi-es7-async-handler

async handler support for hapijs apps

npm version

You can use this plugin to add async handler function to your hapi projects.

requiements

You need es7 supported javascript development environment or use Typescript

Usage

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);
  }
});

Readme

Keywords

none

Package Sidebar

Install

npm i hapi-es7-async-handler

Weekly Downloads

7

Version

1.0.11

License

MIT

Last publish

Collaborators

  • eseom