aws-api-gateway-client
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -7,2 +7,21 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* | ||
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
/* eslint max-len: ["error", 100]*/ | ||
// import 'babel-polyfill'; | ||
var _urlTemplate = require('url-template'); | ||
@@ -18,67 +37,29 @@ | ||
/* | ||
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
/* eslint max-len: ["error", 100]*/ | ||
// import 'babel-polyfill'; | ||
var apigClientFactory = {}; | ||
apigClientFactory.newClient = function (config) { | ||
var removeEmpty = function removeEmpty(obj) { | ||
Object.keys(obj).forEach(function (key) { | ||
return obj[key] && _typeof(obj[key]) === 'object' && removeEmpty(obj[key]) || obj[key] === undefined && delete obj[key]; | ||
}); | ||
return obj; | ||
}; | ||
apigClientFactory.newClient = function () { | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var apigClient = {}; | ||
if (config === undefined) { | ||
config = { | ||
accessKey: '', | ||
secretKey: '', | ||
sessionToken: '', | ||
region: '', | ||
apiKey: undefined, | ||
invokeUrl: '', | ||
service: '', | ||
defaultContentType: 'application/json', | ||
defaultAcceptType: 'application/json', | ||
systemClockOffset: 0 | ||
}; | ||
} | ||
if (typeof config.accessKey === 'undefined') { | ||
config.accessKey = ''; | ||
} | ||
if (typeof config.secretKey === 'undefined') { | ||
config.secretKey = ''; | ||
} | ||
if (typeof config.apiKey === 'undefined') { | ||
config.apiKey = ''; | ||
} | ||
if (typeof config.sessionToken === 'undefined') { | ||
config.sessionToken = ''; | ||
} | ||
if (typeof config.region === 'undefined') { | ||
config.region = 'us-east-1'; | ||
} | ||
if (typeof config.service === 'undefined') { | ||
config.service = 'execute-api'; | ||
} | ||
// If defaultContentType is not defined then default to application/json | ||
if (typeof config.defaultContentType === 'undefined') { | ||
config.defaultContentType = 'application/json'; | ||
} | ||
// If defaultAcceptType is not defined then default to application/json | ||
if (typeof config.defaultAcceptType === 'undefined') { | ||
config.defaultAcceptType = 'application/json'; | ||
} | ||
if (typeof config.systemClockOffset === 'undefined') { | ||
config.systemClockOffset = 0; | ||
} | ||
config = Object.assign({ | ||
accessKey: '', | ||
secretKey: '', | ||
sessionToken: '', | ||
region: 'us-east-1', | ||
apiKey: '', | ||
invokeUrl: '', | ||
service: 'execute-api', | ||
defaultContentType: 'application/json', | ||
defaultAcceptType: 'application/json', | ||
systemClockOffset: 0 | ||
}, removeEmpty(config)); | ||
// extract endpoint and path from url | ||
@@ -85,0 +66,0 @@ var invokeUrl = config.invokeUrl; |
@@ -190,6 +190,4 @@ 'use strict'; | ||
var body = _utils2.default.copy(request.body); | ||
// override request body and set to empty when signing GET requests | ||
if (body === undefined || verb === 'GET') { | ||
body = ''; | ||
} else { | ||
// stringify request body | ||
if (body) { | ||
body = JSON.stringify(body); | ||
@@ -196,0 +194,0 @@ } |
@@ -80,5 +80,2 @@ 'use strict'; | ||
var body = _utils2.default.copy(request.body); | ||
if (body === undefined) { | ||
body = ''; | ||
} | ||
@@ -85,0 +82,0 @@ var url = config.endpoint + path; |
{ | ||
"name": "aws-api-gateway-client", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "A moduel for AWS API Gateway client", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32838
515