hapi-versioning

0.0.3 • Public • Published

hapi-versioning


##Version handling for Hapi.js

###WHY? We want to keep our API clean being able to call /users or /users/2/follow/1 without adding version number /api/v1/users and api/v2/users

with this Hapi.plugin you can just pass the pattern and header

{
    register: require('hapi-versioning'),
    options: {
        pattern: /^(v[1-9])$/,
        header: 'ourversion'
    }
},

That will check the header (only if its not set in the url) on evevry request and will redirect to thr right path.

for ex'

{
    register: require('hapi-versioning'),
    options: {} //set to default header.version = v1
},


header: { version: v1 }
url: /hello/world
//Will redirect to: url: /v1/hello/world

** url will override the header all the time

Checkout the test for more examples

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    2
  • 0.0.2
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i hapi-versioning

Weekly Downloads

4

Version

0.0.3

License

ISC

Last publish

Collaborators

  • doron2402