hapi-router-coffee
An Opinionated Route Loader for Hapi for CoffeeScript files.
Last updated 4 years ago by ethan_mick .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hapi-router-coffee 
SYNC missed versions from official npm registry.

Hapi Router Coffee

Build Status Coverage Status

An Opinionated Route Loader for Hapi for CoffeeScript files.

This fork does two things, which may interest you:

  1. Written in CoffeeScript (and not compiled to JS), so it can autoload .coffee files.
  2. Allows you to pass options to the routes, and merge in the options already on the route.

Setup

$ npm install hapi-router-coffee --save

I assume you're writing in CoffeeScript, right?

server.register {
  register: require('hapi-router-coffee')
  options:
    routesDir: "#{__dirname}/routes/"
}, (err)->
  throw err if err
}

Options

The following required options should be provided at registration:

  • routesDir: the path to your routes directory
  • routesOptions : Options to pass into the config of each route.

Note that the options are not really needed, since you can just use the Hapi server for options. This may be useful in the future though!

server = new Hapi.Server({
    connections:
      routes:
        payload:
          timeout: no # Sets payload timeout to false on ALL routes.
})

Specifying Routes

Any .js or .coffee files in your routes directory will be loaded - supports nested routes.

Example route file:

module.exports = [
  {
    path: '/test1',
    method: 'GET',
    handler: function (request, reply) {
      reply('hello');
    }
  },
  {
    path: '/test2',
    method: 'GET',
    handler: function (request, reply) {
      reply('hello');
    }
  }
]

Current Tags

  • 1.5.0                                ...           latest (4 years ago)

6 Versions

  • 1.5.0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (8)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |