Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

giuseppe-version-plugin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

giuseppe-version-plugin

Giuseppe plugin that adds a `@Version` route modificator to add versioning to an api.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
6
500%
Maintainers
1
Weekly downloads
 
Created
Source

giuseppe-version-plugin

This is a plugin for giuseppe. This plugin adds a @Version route modificator to add versioning to an api.

Build Status Build Status Coverage Status semantic-release npm Greenkeeper badge

Installation

To install this package, simply run

npm i giuseppe-version-plugin -S

How to use

Here is a brief example of how to add the plugin to giuseppe:

import { Giuseppe } from 'giuseppe';
import { GiuseppeVersionPlugin } from 'giuseppe-version-plugin';

const app = new Giuseppe();
app.registerPlugin(new GiuseppeVersionPlugin());
app.start();

Versionining

When you want to version your routes, you can use the @Version decorator to do so. It is configurable, which header name should be used and from and until which version the function is valid. When a version header can't be parsed, it defaults to V1 and if no matching version is found, a 404 is returned.

@Controller()
export class VersionedController {
    @Version({ from: 1, until: 1 })
    @Get()
    public functionV1(): string {
        return 'hello from v1';
    }

    @Version({ from: 2, until: 4 })
    @Get()
    public functionV2UntilV4(): string {
        return 'hello from v2 until v4';
    }

    @Version({ from: 5 })
    @Get()
    public functionV5(): string {
        return 'hello from v5 until Infinity.';
    }
}

The default header is Accept-Version.

Changelog

The changelog is generated by semantic release and is located under the release section.

Licence

This software is licenced under the MIT licence.

Keywords

giuseppe

FAQs

Package last updated on 16 Jan 2018

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