New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-version

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-version

Hapi route versioning using custom header

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status Coverage Status Dependency Status

Codeship Status for corintho/hapi-version

NPM

Description

This package allows a simple versioning scheme to be applied with Hapi servers.

Basic Usage

  • Install package with: npm install --save hapi-version
  • Include it as a requirement for your server
server.register({
  register: require('hapi-version')
}, function(err) {
  if(err) {
    throw err; //Bad things going on
  }
});
  • Declare your routes to have version information
server.route({
  method: 'GET',
  path: '/versioned',
  handler: function(req, res) {
    res('Hello world!');
  },
  config: {
    plugins: {
      versions: {
        '1.0.0': true,
        '2.0.0': function(req, res) {
          res('Hello world 2.0!');
        }
      }
    }
  }
});
  • When sending requests, include an 'Accept-Version' header with the proper version
curl --header "Accept-Version: 2.0.0" <host_url>/versioned
  • If the requested version cannot be matched in the service, a 400 response (Bad Request) is returned

Advanced usage

More details on the project wiki.

Also, a look on the tests source code can be very enlightening

Running from source

  • Check out the repository
  • Use npm test to run the Lab test suite, including overall coverage statistics
  • Use npm run coverage to generate the Lab coverage report written to coverage.html file
  • Use npm run watch continuously run the tests while editing the source code. It requires nodemon to be installed globally

Keywords

FAQs

Package last updated on 14 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc