hapi-api-version-support

0.0.7 • Public • Published

This is a Hapi plugin to support API versioning.

Note: This is tailored for our project requirements.

Usage:

Install: npm install

Usage in Hapi Server:

server.register({
        register: require('./../api-version'),
        options: {
            pattern: /^(application\/user-management-)(.*?)(\+json)/,
            header: 'content-type',
            supported_versions: ['1.0', '1.1','1.2'],
            default_version: '1.0'
        }
    },(err)=>{
        //.....
    ))

Route Configuration:

    //Request to /service1 with header application/user-management-1.1+json
    server.route({
        method: 'GET',
        path: '/1.1/service1',
        handler: function (request, reply) {

            return reply('Service 1: 1.1 Version');
        }
    });
    //Default Implementation of Service 1
    //Request to /service1 with header application/user-management-1.0+json
    server.route({
            method: 'GET',
            path: '/service1',
            handler: function (request, reply) {
                    return reply('Service 1: 1.0 Default Version');
            }
        });

Readme

Keywords

none

Package Sidebar

Install

npm i hapi-api-version-support

Weekly Downloads

8

Version

0.0.7

License

none

Last publish

Collaborators

  • ssriram83