Skip to content

Declare hapi routes from a manifest.json file

Notifications You must be signed in to change notification settings

jmac105/hapi-routify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hapi-routify

npm travis-status

Just some lines of code to let you declare hapi routes from a manifest.json

The plugin is actually only a server.route hapi call, nothing more.

nodei.co

Install

npm install --save hapi-routify

Why ?

If you use hapi with glue or rejoice, you may want to declare the routes of your application from the manifest.json:

{
    "server": {
        "app": {
            "name": "simple proxy"
        }
    },
    "connections": [{
        "port": 8000,
        "host": "localhost",
        "labels": ["proxy"]
    }],
    "registrations": [{
      "plugin": "h2o2"
    }, {
      "plugin": {
        "register": "hapi-routify",
        "options": {
          "routes": [{
            "method": "GET",
            "path": "/{path*}",
            "handler": {
              "proxy": {
                "host": "localhost",
                "port": 1337
              }
            }
          }]
        }
      }
    }, {
      "plugin": "blipp"
    }]
}

This example uses h2o2 to proxy all your requests to http://localhost:1337.

If you use rejoice there are actually two ways to provide your own handler:

Options

Dependencies

Package Version Dev
babel-cli ^6.2.0
babel-core ^6.2.1
babel-preset-es2015 ^6.1.18
blipp ^2.3.0
code ^4.0.0
h2o2 ^5.0.0
hapi ^16.1.1
husky ^0.13.3
lab ^14.0.1
node-readme ^0.1.9
npm-run-all ^4.0.2
rejoice ^4.0.0

Contribute

Contributions are welcome! Open an issue to report bugs or request features. To contribute with code:

  • clone this repository
  • install the dependencies with npm install
  • make your changes to the files in the src/ folder
  • write tests using lab in the test/ folder
  • run tests with npm test. try to keep test coverage about 100%
  • edit the .README.md file and build the project again (npm run compile)
  • send a pull request against the master branch

Author

g-div

Inspired by garthk's hapi-restify.js gist.

License

About

Declare hapi routes from a manifest.json file

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%