Skip to content

Instantly share code, notes, and snippets.

@thebergamo
Created December 4, 2015 16:44
Show Gist options
  • Save thebergamo/e02147f717954a820bf0 to your computer and use it in GitHub Desktop.
Save thebergamo/e02147f717954a820bf0 to your computer and use it in GitHub Desktop.
Decorate plugin
'use strict';
const Boom = require('boom');
exports.register = register;
exports.register.attributes = {
name: 'reply-decorates',
version: '1.0.0'
};
function register (server, options, next) {
// create yours decorates
server.decorate('reply', 'notFound', notFound);
server.decorate('reply', 'badImplementation', badImpl);
server.decorate('reply', 'unauthorized', unauthorized);
next();
};
function notFound (messsage) {
return this.response(Boom.notFound(message));
}
function badImpl (messsage) {
return this.response(Boom.badImplementation(message));
}
function unauthorized (messsage) {
return this.response(Boom.unauthorized(message));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment