@makemydeal/cai-api-version-manager

1.0.8 • Public • Published

@makemydeal/cai-api-version-manager

This package will allow for header based routing/versioning in APIs. It will follow Cox API Cookbook standards listed here: https://ghe.coxautoinc.com/CoxAuto/api-cookbook/blob/master/cookbook-v2.md#8-api-versioning

Usage

In order to use this, you simply can instantiate a copy of the generic class CoxHeaderApiVersionManager or the API Gateway specific class ApiGatewayCoxApiVersionManager. The API Gateway specific class has an additional function to read ApiGatewayProxyEvent and determine the version.

Example

CoxHeaderApiVersionManager

    const versisonManager = new CoxHeaderApiVersionManager(DEFAULT_VERSION);
    const version = versionManager.read(httpMethod, headers);
    console.log(version);

ApiGatewayCoxAutoVersionManager

const handler: Handler<APIGatewayProxyEvent> = async (event, context): Promise<APIGatewayProxyResult> => {
    const versionManager = new ApiGatewayCoxApiVersionManager(DEFAULT_VERSION);
    const version = versionManager.readApiGateway(event);
    console.log(version);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @makemydeal/cai-api-version-manager

Weekly Downloads

128

Version

1.0.8

License

ISC

Unpacked Size

15 kB

Total Files

11

Last publish

Collaborators

  • mmd-devops