1.1.0 • Published 8 years ago

drboom v1.1.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Dr. Boom

npm i drboom

Dr. Boom detects errors being passed into Hapi's HTTP replies and converts them into the appropriate HTTP Error.

This allows you to pass the resulting error and result from a database query to reply without having to do special error handling.

Example

For example, to detect Joi validation errors:

let Hapi = require('hapi');
server.register([
  {
    register: require('drboom'),
    options: {
      plugins: [require('drboom-joi')({})]
    }
  }
], (err) => {
    // ...
});

Then when a route serves an a Joi validation result as the first argument, the reply is automatically converted to an HTTP 400 Bad Request error.

Writing a Dr. Boom Plugin

A Dr. Boom plugin is an object with two functions, detect and handle.

detect(value, request, reply)

value is the first argument sent to reply.

return: Boolean, false meaning that you didn't detect an error your handler can deal with.

handle(value, request, reply)

value is the first argument sent to reply.

return: Boom error or falsey.

1.1.0

8 years ago

1.0.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago