@makemydeal/cai-api-version-manager
v1.0.8
Published
API Header based routing version management
Downloads
317
Readme
@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);
}