<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wes Tyler on Medium]]></title>
        <description><![CDATA[Stories by Wes Tyler on Medium]]></description>
        <link>https://medium.com/@westyler?source=rss-2d671c058857------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dSTR_FQCfTlE7zgQQIlseg.png</url>
            <title>Stories by Wes Tyler on Medium</title>
            <link>https://medium.com/@westyler?source=rss-2d671c058857------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:52:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@westyler/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Migrating to hapi v17: plugin structure and Glue manifests]]></title>
            <link>https://medium.com/@westyler/migrating-to-hapi-v17-plugin-structure-and-glue-manifests-a7b3c3d551f2?source=rss-2d671c058857------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7b3c3d551f2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hapijs]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[hapi]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Wes Tyler]]></dc:creator>
            <pubDate>Mon, 06 Nov 2017 21:20:20 GMT</pubDate>
            <atom:updated>2017-11-08T20:27:08.564Z</atom:updated>
            <content:encoded><![CDATA[<p>Hapi v17 is upon us! I’m not going to discuss the full scope of what’s changed in the latest major release of hapi, as there are far more qualified people than I to tell that story. However, I think we should talk about plugins. For those using Glue to register plugins, don’t skip ahead! Or do. Your choice on how much you want to learn here.</p><p><strong>Changes to the plugin registration process in v17:</strong></p><ol><li>Async/await</li></ol><p>First and foremost, the entire hapi api has moved away from callbacks and toward async/await. This brings us immediately to the first thing you need to be aware of when migrating your plugins and services to hapi 17: you will now need to await server.register. Let’s take a look at how a plugin is registered in hapi 16 versus the same action in 17.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c34e8ef418032425b41c2cd3957f1b21/href">https://medium.com/media/c34e8ef418032425b41c2cd3957f1b21/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4ca5166efda0f6731945c822da1105d/href">https://medium.com/media/a4ca5166efda0f6731945c822da1105d/href</a></iframe><p>2. Plugin object contract.</p><p>The next major thing you need to know about plugin registration is that plugins are now just simple objects instead of functions. This also means that plugin attributes like the name and version are flattened on the object to be siblings of the required register function. Furthermore, the plugin’s register function no longer takes a next callback and now has the signature async function(server, options).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5d736a4a541b468f3c2f6bccc77cce7/href">https://medium.com/media/b5d736a4a541b468f3c2f6bccc77cce7/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/347c15e814dfbbcd431d7cf0056e35cf/href">https://medium.com/media/347c15e814dfbbcd431d7cf0056e35cf/href</a></iframe><p>3. Multiple server connections.</p><p>With version 17, hapi has entirely dropped support for multiple connections on a single server. This means that if you were using a single server to host, for example, public web and private admin plugins/routes, you’ll now need to create multiple servers to host each individually. As a result, it also means that if you were using the select option on your plugin registrations to control which connections get which plugins, you can stop worrying about it. That property is gone as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6aa92bb4a9b209e61511bf9dc38b6560/href">https://medium.com/media/6aa92bb4a9b209e61511bf9dc38b6560/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4963fafac306e8f6d8d585da3dd5695/href">https://medium.com/media/f4963fafac306e8f6d8d585da3dd5695/href</a></iframe><p>There are <strong><em>many </em></strong>other hapi v17 changes and features that I cannot begin to cover here. I strongly encourage you to peruse the <a href="https://github.com/hapijs/hapi/issues/3658">v17 Release Notes</a>. But for now, let’s wrap up the hapi portion of this story by putting it all together and migrating a hapi v16 plugin registration flow to hapi 17.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5049a2949d02f1d23f8d0e14e1719f18/href">https://medium.com/media/5049a2949d02f1d23f8d0e14e1719f18/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d1619aaaea932b3dce9a3620c2f672d/href">https://medium.com/media/5d1619aaaea932b3dce9a3620c2f672d/href</a></iframe><p>That’s it! Not too bad, huh?</p><p>Let’s move on to part 2 of this discussion: migrating Glue manifests from hapi v16/Glue v4 to hapi v17/Glue v5. There are really only three changes here as well, and two of them are the same as the above: Glue is now fully async/await, and your plugin shape should be a bit different. As before, rather than utilizing a callback Glue.compose(manifest, composeOptions, (err, server) =&gt; {}), you will now need to<br>const server = await Glue.compose(manifest, composeOptions).</p><p>The `composeOptions` have also changed slightly:</p><ol><li>preConnections — removed<br>Predictably, the `preConnections` function previously executed prior to setting server connections has been deprecated.</li><li>preRegister — changed<br>The `preRegister` function is still executed prior to registering plugins to the server. However, its signature has changed from function (server, next) {} to async function(server) {} .</li><li>relativeTo — no change<br>The `relativeTo` option remains the same.</li></ol><p>And, rather than exporting a register function with attributes, you should now simply export the plugin object described earlier in this post (see? told you not to skip ahead). That really only leaves us with changes to the manifest itself:</p><ol><li>options — no change<br>The optional registration `options` passed to server.register are retained.</li><li>server — changed<br>The only change here is that you should pass your `port` configuration directly to the `server` object here instead of the deprecated `connections` object below.</li><li>connections — removed<br>The `connections` property has been deprecated in line with the removal of connections from hapi itself.</li><li>registrations — renamed to register and changed significantly.<br>This is the big one for Glue v5. In Glue v4, `registrations` was an array of plugin registration objects, each passed individually to hapi’s server.register . Now, `register` is an object with two properties: plugins and options. Let’s take a closer look at the new register object.</li></ol><p>register.plugins <br>The `plugins` property is an array of, you guessed it, plugins to be registered. These plugins can each take one of three forms: a string to be required, an object with the plugin property to be required, or an object with the plugin property containing the actual <a href="https://github.com/hapijs/hapi/blob/master/API.md#plugins">plugin object</a> to be registered directly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f12932667b67b52702fc8a84412add80/href">https://medium.com/media/f12932667b67b52702fc8a84412add80/href</a></iframe><p>Additionally, the object entries in the `plugins` array can optionally contain an `options` property, which are the plugin-level options passed to the plugin’s register method at registration time, and/or override registration-options such as routes or once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ffb54c03dbf7bcbb1d6e465598e16b6/href">https://medium.com/media/1ffb54c03dbf7bcbb1d6e465598e16b6/href</a></iframe><p>register.options<br>The `options` property is an optional object that contains <a href="https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options">registration options</a> to apply to all plugins in the plugins array. If a registration option, such as once, is specified both on the register.options object and on the individual register.plugins array item then the value on the plugins array item will be used as an override value for that plugin only.</p><p>Alright, that was a lot of details. Let’s finish up by comparing a sample Glue v4 manifest and the equivalent manifest for Glue v5.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/045310a9c505c2f11aa59513362b20d3/href">https://medium.com/media/045310a9c505c2f11aa59513362b20d3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd3ad25bebec6499e2fc5aeb9da2c887/href">https://medium.com/media/dd3ad25bebec6499e2fc5aeb9da2c887/href</a></iframe><p>If you run into any problems, believe I have mislead you in any way, or think I missed something please let me know! You can find me in the <a href="https://github.com/hapijs/glue/issues">Glue Issues</a> on Github or on <a href="https://twitter.com/westyler1">Twitter</a>. Or you can always leave comments here on Medium.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7b3c3d551f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>