maissani / trailpack-hapi

:package: Hapi.js Trailpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

trailpack-hapi

Gitter NPM version Build status Dependency Status Code Climate

Hapi Trailpack. This pack binds the routes compiled in trailpack-router to a Hapi Server.

Usage

Load in your trailpack config.

// config/trailpack.js
module.exports = {
  // ...
  packs: [
    require('trailpack-core'),
    require('trailpack-router'),
    require('trailpack-hapi')
  ]
}

View Config

Choose a template engine.

// config/views.js
module.exports = {
  engine: 'handlebars'
}

Then simply write your views in a directory called 'templates'!

This feature has been tested with Jade and Handlebars. TODO: Put this in yeoman?

Configuration

See config/web.js for an example.

port

The port to listen on. 3000 by default. Can also be set via the PORT environment variable.

Hapi Plugins

Register your hapi plugins by adding them to the web.js config in typical Hapi plugin format. See: http://hapijs.com/tutorials/plugins#loading-a-plugin

// config/web.js
module.exports = {
  plugins: [
    {
      register: require('vision'),
      options: { }
    },
    {
      register: require('inert'),
      options: { }
    },
    // ...
  ]
}

Hapi Views

// config/web.js
module.exports = {
  views: {
    engines: {
      html: require('some-view-engine')
    },
    path: 'views'
  }
}

Contributing

We love contributions! In order to be able to review your code efficiently, please keep the following in mind:

  1. Pull Requests (PRs) must include new and/or updated tests, and all tests must pass.
  2. Use eslint! See the eslintConfig in package.json.
  3. Please reference the relevant issue in your Pull Request.

License

MIT

About

:package: Hapi.js Trailpack

License:MIT License


Languages

Language:JavaScript 100.0%