warbrett / boomstick

Hapi plugin to transform application errors into proper response codes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Hapi plugin to transform application errors into proper response codes

License:MIT License


Languages

Language:JavaScript 100.0%