Socket
Socket
Sign inDemoInstall

hapi-boom-decorators

Package Overview
Dependencies
31
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
442
decreased by-54.43%
Maintainers
1
Install size
78.4 kB
Created
Weekly downloads
 

Changelog

Source

[4.1.2] - 2018-11-04

Changed

  • Update boom to version 7.2.2

Readme

Source

hapi-boom-decorators

Greenkeeper badge

Known Vulnerabilities js-semistandard-style Circle CI

NPM

A plugin for hapi.js to make responding with Boom errors a little less verbose by decorating the response toolkit with equivilent functions.

This module is tested against Node.js versions 8 and 10. The minimum required version of hapi.js is 17. If you require compatibility with an older version use version 3.0.1 or older.

Install

npm install hapi-boom-decorators --save

Add plugin to hapi server

const hapiBoomDecorators = require('hapi-boom-decorators');

const server = new Hapi.Server();

await server.register(hapiBoomDecorators);

API

The normal way of replying with a Boom error response:

const Boom = require('boom');

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

With hapi-boom-decorators:

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

Check the Boom API documentation for all Boom error types. Every 4xx and 5xxx error, as well as boomify can be called on the response toolkit.

Keywords

FAQs

Last updated on 04 Nov 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc