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

hapi-version-prereq

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-version-prereq

automgaically populates the version prereq for routes that support it

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
6
Weekly downloads
 
Created
Source

#Hapi-version-prereq Build Status NPM version Dependencies

Hapi plugin for automagically populating the version header on routes that support it. At OT we use a mix of url-versioning and header-versioning. In some cases our APIs need to support both. This module represents some shared code for our narrow use-case.

installation:

npm install hapi-version-prereq

usage:

var hapi = require("hapi");
var joi = require("joi");

var server = Hapi.createServer('127.0.0.1', 3000, {});

server.route([{
  method: 'GET',
  path: '/v1/my-url',
  config: {
    handler: function(request, reply){
      reply(request.pre.version)
    }
  }
},
{
  method: 'GET',
  path: '/my-url',
  config: {
    handler: function(request, reply){
      reply(request.pre.version)
    },
    validate: {
      headers: {
        accept: joi.string().regex(/application\/vnd.myorg.mytype.v1\+json/)
      }
    }
  }
}]);

server.pack.register([
  {
    plugin: require('hapi-version-prereq'),
    options: {}
  }], function(err){
    if(err){
      throw err;
    }

    server.start(function(){
      server.log('server started');
    });
});

  • /v1/my-url => { version: 'v1', mode: 'url' }
  • /my-url => { version: 'v1', mode: 'header' }

Keywords

FAQs

Package last updated on 30 Jun 2017

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