hapi-as-promised

2.0.0 • Public • Published

hapi-as-promised Build Status NPM version

A Hapi plugin that allows you to reply with promises in your request handlers.

Usage

server.route({
  method: 'GET'
  path: '/',
  handler: function (request, reply) {
    reply(promise);
  }
});

The plugin will automatically intercept all replies that are thenables (have a property then that is a function) and resolve them. You can still chain methods to your reply like code. Only the reply body itself is modified. Error behavior is unchanged. A rejection with err.isBoom === true will be serialized and sent to the client, while all others will be transformed into 500s.

Readme

Keywords

Package Sidebar

Install

npm i hapi-as-promised

Weekly Downloads

1

Version

2.0.0

License

MIT

Last publish

Collaborators

  • bendrucker