Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Created March 20, 2014 11:01
Show Gist options
  • Select an option

  • Save RyanHirsch/9661403 to your computer and use it in GitHub Desktop.

Select an option

Save RyanHirsch/9661403 to your computer and use it in GitHub Desktop.
Hapi Pack through code or through Composer
{
"servers": [
{
"port" : 8000,
"labels": ["public"]
}
],
"plugins": {
"capi-web": { }
}
}
var Hapi = require('hapi');
var pack = new Hapi.Pack();
pack.server(8000, { labels: ['public'] });
pack.require('capi-web', {}, function(err) {
});
pack.start(function () {
console.log('All servers started');
});
@RyanHirsch
Copy link
Author

Comparison between creating a pack though code or using a config.json to let the hapi CLI create the necessary packs. My index.js works as expected, but the config.json with composer does not work. Not working, meaning it starts up, but none of the routes provided by capi-web work, just get 404 for all routes.

@savardc
Copy link

savardc commented Mar 20, 2014

The labels need to be in options, like:

"servers": [
{
  "port": 8000,
  "options": {
    "labels": ['public']
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment