hapi 8 is coming. Are you ready?

For those of you who don't know, hapi is a web framework with a rapidly growing community led by Eran Hammer.

Over the last month, a lot of work has gone into it to prepare for the release of version 8.0.0. hapi 8 represents the biggest release since the start of the framework, and with it come quite a few changes.

No more packs

That's right, those confusing pack things are gone. If you used them, though, don't worry. The functionality still exists, just in different ways. Instead of a pack that contains servers, we now have a server that contains connections. You can still create a server with multiple connections, but if you only need one; everything will feel much more straightforward and intuitive.

If you're used to using Pack.compose you'll want to check out glue, which has taken over that functionality.

Promise support

That's right folks, you asked for it and hapi listened. You can now reply() with a promise in handlers, as well as use them in server methods. hapi will resolve the promise and send the correct data for you.

More consistent reply interface

Gone is the distinction between next and reply. Instead, in the majority of places you'll receive the same reply interface as you do in request handlers.

This does mean a few changes, however. If you want to pass control from a server extension back to the chain, call reply.continue() instead of an empty reply. Calling reply() as before will instead send an empty response, and that's probably not what you want.

Extensible reply interface

Speaking of the reply interface, you can add your own methods to it now!

Ever wanted a reply.success() method so you don't have to keep typing out reply({ status: 'success' })? Well, now you can have it. In fact, you can attach any method you want to the reply interface and use it throughout your entire server.

A lot of stuff got deleted

As part of the push for simplicity, a lot of useless and/or redundant functionality was removed. As I mentioned, packs are gone and the Pack.compose functionality has been moved to glue.

Also removed is Hapi.error. If you were using it before you should update your code to use boom directly.

The deprecated Hapi.createServer method has been removed completely, in favor of simply calling new Hapi.Server().

Hapi.version has also been removed. If you need to know what version of hapi you're using, you should simply require hapi's package.json (which is easy to do, something like var hapiPkg = require('hapi/package'); works nicely).

The hapi CLI command has also been removed from the framework. If you were using it, check out the rejoice module for that functionality.

Lots more

These are just a few of the major changes that are coming. For a complete list, do yourself a favor and check out the release notes.

Get ready!

hapi 8.0.0 is set to be released this Thursday, December 11th. If you maintain a plugin, or you're using hapi for your projects, I strongly encourage you to take a look at updating.

As mentioned in the support schedule the last version of hapi before 8.0 that will receive any support at all is 7.5, which will only receive critical and security related updates, and only until March 4th of 2015.

Don't drag your feet, start updating as soon as you can!

You might also enjoy reading:

Blog Archives: