Skip to content

eseom/hapi-es7-async-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE

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.

hapijs/hapi#3429

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

Releases

No releases published

Packages

No packages published