brainsiq / hapi-boom-decorators

Decorates a Hapi server's response toolkit with functions to make it easy to reply with Boom errors
MIT License
29 stars 6 forks source link

Hapi v17 Support #51

Closed timcosta closed 6 years ago

timcosta commented 6 years ago

Overview

If you are not aware yet, Hapi v17 is making the transition from callbacks to async/await, as well as deprecating some other rarely used functionality. This is a breaking change that may make your plugin no longer compatible with the Hapi API.

Changelog

Draft release notes can be found here: https://github.com/hapijs/hapi/issues/3658

Target Release

The target release date for v17 is the beginning of November.

Tasks

Notes

brainsiq commented 6 years ago

I will update the plugin

brainsiq commented 6 years ago

I have decided for now not to update this module to work with hapi v17. The new API for returning responses seems to make this plugin unnecessary as the example usage below shows:

With hapi v17 and no plugins:

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

With a plugin for decorating the toolkit with boom functions:

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

There is very little difference in terms of verbosity, which was the main driver for creating this module in the first place. If anyone can convince me otherwise I am open to updating.

BigWillie commented 6 years ago

Without the plugin, you have to require boom in all your route files... const Boom = require('boom'); However, with the plugin - you just call it.. return h.notFound();

brainsiq commented 6 years ago

@BigWillie I'd done most of the work already so I've just gone and published a new version (4.0.0) for hapi 17.