hapipal / boilerplate

A friendly, proven starting place for your next hapi plugin or deployment
https://hapipal.com
184 stars 26 forks source link

hapi 17 comptability? #44

Closed jamesdixon closed 6 years ago

jamesdixon commented 6 years ago

heyo!

now that h17 is out, i was thinking about starting from the boilerplate and re-structuring my application a bit using this boilerplate. any thoughts on h17 compatibility?

cheers, james

devinivy commented 6 years ago

It's coming :) As you've seen haute-couture is just about to land in https://github.com/devinivy/haute-couture/pull/36, at which point the upgrade on this repo should be pretty straightforward. Upgrading the flavors will take a little more time. If you want to take a crack at any of it, feel free! I will probably work on it tomorrow and Sunday.

jamesdixon commented 6 years ago

suh-weet! I actually was taking a crack at updating labbable last night, but the tests were throwing me for loop because of the whole async/await flow.

devinivy commented 6 years ago

This is a bit of a side conversation that I'd be happy to take to slack/gitter/email or an issue on the labbable repo, but I wasn't planning on upgrading labbable since it's so much easier to asynchronously return a server using async/await than using callbacks, so the module is a lot less useful than before. That said, I would certainly publish an upgrade, and I'm open to different perspectives on it. Here's the boilerplate code I'm imagining (from this thread),

module.exports = (async () => {

    const server = await Glue.compose(manifest);

    await server.initialize();

    if (module.parent) {
        return server;
    }

    await server.start();

    console.log(`Server started at ${server.info.uri}`);

    return server;
})();
jamesdixon commented 6 years ago

@devinivy I gave this a shot, but not having any luck including it in tests via server = await require('../server');. Let me know if you have a moment to chat on Slack hapi hour

jamesdixon commented 6 years ago

@devinivy nix that. I had forgotten to change return; to return server;. Works as expected. Thanks!

As for upgrading labbable, do you think it's worth adding this snippet to the docs to point out there is a better way going forward?

devinivy commented 6 years ago

Yes, but I'd like to play with the snippet a bit more first– it probably needs a little more work to handle failures properly.

devinivy commented 6 years ago

Here's what I've come-up with so far, open to feedback https://github.com/devinivy/boilerplate-api/pull/45

jamesdixon commented 6 years ago

@devinivy I'll take a look as soon as I get my project completely ported to v17. Looking forward to trying this out!

devinivy commented 6 years ago

Resolved by #45