Created
December 4, 2015 16:44
-
-
Save thebergamo/e02147f717954a820bf0 to your computer and use it in GitHub Desktop.
Decorate plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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