/boomstick

Hapi plugin to transform application errors into proper response codes

Primary LanguageJavaScriptMIT LicenseMIT

boomstick

Travis Build Status

Hapi plugin to transform application errors into boom error responses.

Usage

var hapi = require('hapi');
var boomstick = require('boomstick');

var server = new hapi.Server();
server.connection();

server.register({
  register: boomstick,
  options: {
    success: function(request){
      return !(request.response instanceof Error);
    },
    errors: {
      badRequest: function(request){
        return (request.response instanceof InvalidRequestError);
      },
      notFound: function(request){
        return (request.response.code === 404);
      }
    }
  }
}, function(){
  server.start();
});

License

MIT