Giter Club home page Giter Club logo

trailpack-hapi's Introduction

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'
  }
}

Doing other things with Hapi

The Hapi server lives on the Trails global object at app.packs.hapi.server.

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

trailpack-hapi's People

Contributors

tjwebb avatar weyj4 avatar konstantinzolotarev avatar greenkeeperio-bot avatar wbprice avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.