New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-boom-decorators

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-boom-decorators

Decorates a Hapi server's reply interface with functions to make it easy to reply with Boom errors

  • 2.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
528
decreased by-24.46%
Maintainers
1
Weekly downloads
 
Created
Source

hapi-boom-decorators

Known Vulnerabilities Standard - JavaScript Style Guide Circle CI

NPM

A plugin for hapi.js to make responding with boom errors a little less verbose by decorating the reply interface with equivilent functions. This module is tested against the latest versions of Node.js 4, 6 and 7.

Install

npm install hapi-boom-decorators --save

Register Plugin

server.register({
  register: require('hapi-boom-decorators')
}, err => {
  ...
})

API

Standard way of replying with boom response:

server.route({
  method: 'GET',
  path: '/resource/{id}',
  handler: (request, reply) => {
    reply(Boom.notFound())
  }
})

New way:

server.route({
  method: 'GET',
  path: '/resource/{id}',
  handler: (request, reply) => {
    reply.notFound()
  }
})

Check the boom documentation for all available functions. Every 4xx and 5xx error type has been implemented, and the parameters to each function in hapi-boom-decorators are the same as the parameters to the boom function. In addition:

  • wrap - reply(Boom.wrap(err, 500, 'a message')) can be written as reply.boom(500, err, 'a message')
  • create - reply(Boom.create(500, 'a message', {})) can be written as reply.boom(500, 'a message', {})

Keywords

FAQs

Package last updated on 19 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc