fritzy / drboom-gatepost

Catch gatepost errors and turn them into hapi Boom errors.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dr. Boom: Gatepost

npm i drboom-gatepost

Auto-cast errors from Gatepost into Hapi HTTP Errors.

##Example / Boilerplate

Plugin registration boilerplate:

var hapi = require('hapi');
var config = require('./config.json');
var Boom = require('boom');
var Gatepost = require('gatepost')(config.db);

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

server.register([{
    register: require('drboom'), 
    options: {
        plugins: [require('drboom-gatpost')({Gatepost: Gatepost, Boom: Boom})]
    },
}, function (err) {
    server.log(['startup'], 'Loaded pgboom plugin');
    server.start(function (err) {
        //...
    }
});

Now, you can pass your seaquell errors right on through to hapi reply!

function someHandler(request, reply) {
    SomeGatepostModel.method(reply);
});

About

Catch gatepost errors and turn them into hapi Boom errors.

License:MIT License


Languages

Language:JavaScript 100.0%