Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hapi-boom-decorators

brainsiq6.8kMIT4.1.2

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

hapi, boom, decorate, decorator

readme

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.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[4.1.2] - 2018-11-04

Changed

  • Update boom to version 7.2.2

[4.1.1] - 2018-07-25

Security

  • Update boom sub-dependencies to remove vulnerable version of hoek (CVE-2018-3728)

[4.1.0] - 2018-04-07

Added

  • Decorator function for Boom.failedDependency

Changed

  • Tested against hapi.js v17.4.0

[4.0.0] - 2018-12-04

Added

  • Support for hapi.js version 17 and Boom version 7
  • Decorator function for Boom.boomify

Removed

  • Support for hapi.js versions older than 17 and Node.js versions 4, 6 and 7
  • wrap and create decorator functions (use boomify instead)

[3.0.1] - 2017-11-11

  • Updated docs with Hapi v17 information

[3.0.0] - 2017-05-29

Changed

  • Updated boom dependency to version 5.1.0

[2.3.0] - 2017-04-19

Added

  • Support for Boom.teapot()

[2.2.2] - 2016-12-04

Changed

  • Regenerated npm-shrinkwrap.json to remove development dependencies

[2.2.1] - 2016-12-04

Fixed

  • Remove spread operator usage to fix Node 4 support #39
  • Add node 4 back to CI configuration

[2.2.0] - 2016-12-03

Fixed

  • Support creating boom errors with a function signature that is not Boom.[errorType]([message], [data])

e.g. Boom.methodNotAllowed([message], [data], [allow])

[2.1.1] - 2016-12-03

Changed

  • Test against latest versions of node 6 and 7
  • Update dependencies
  • Remove retire.js and test with Snyk

[2.1.0] - 2016-10-07

Changed

  • Test against latest versions of node 4, 5 and 6
  • Update boom dependency

Added

  • Decorate hapi.js reply interface with new boom functions: internal, paymentRequired

[2.0.2] - 2016-09-01

Changed

  • Test against latest hapi version 15
  • Update dependencies
  • Test against latest versions of node 5 and 6

[2.0.1] - 2016-08-14

Changed

  • Test against latest hapi version 14
  • Update dev dependencies (inc changing XO -> JS Standard)

[2.0.0] - 2016-07-14

Changed

  • Update Boom dependency
  • Replace serverTimeout function with serverUnavailable

[1.1.4] - 2016-07-14

Changed

  • Update out of date dependencies (exc. Boom)
  • Test only in latest few versions of node 4.x, 5.x and 6.x

[1.1.3] - 2016-03-19

Changed

  • Test against hapi version 13
  • Update out of date dependencies
  • Test against additional node 4.x and 5.x versions

[1.1.2] - 2016-01-10

Changed

  • Test against hapi version 12
  • Test against additional node version 5.4

[1.1.1] - 2016-01-03

Changed

  • Fix peer dependency conflicts with dev dependencies and build issues
  • Specify minimum node version in package.json

[1.1.0] - 2015-12-27

Added

  • reply.illegal() decorated function for new 451 HTTP response code

Changed

  • Test against additional node versions (5.2 and 5.3)