hapi-as-promised
v2.0.0
Published
A Hapi plugin that allows you to reply with promises in your request handlers
Downloads
18
Readme
hapi-as-promised
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.