Skip to content

Commit

Permalink
Merge pull request #63 from kndt84/update-readme
Browse files Browse the repository at this point in the history
Set region as required param
  • Loading branch information
kndt84 authored Jul 19, 2018
2 parents 0a13e8e + 4a47954 commit 8e14cf6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
33 changes: 11 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ var apigClient = apigClientFactory.newClient(config);
Calls to an API take the form outlined below. Each API call returns a promise, that invokes either a success and failure callback

```
var params = {
//This is where any header, path, or querystring request params go. The key is the parameter named as defined in the API
var pathParams = {
//This is where path request params go.
userId: '1234',
};
// Template syntax follows url-template https://www.npmjs.com/package/url-template
var pathTemplate = '/users/{userID}/profile'
var method = 'GET';
var additionalParams = {
//If there are any unmodeled query parameters or headers that need to be sent with the request you can add them here
//If there are query parameters or headers that need to be sent with the request you can add them here
headers: {
param0: '',
param1: ''
Expand All @@ -55,7 +55,7 @@ var body = {
//This is where you define the body of the request
};
apigClient.invokeApi(params, pathTemplate, method, additionalParams, body)
apigClient.invokeApi(pathParams, pathTemplate, method, additionalParams, body)
.then(function(result){
//This is where you would put a success callback
}).catch( function(result){
Expand All @@ -68,11 +68,11 @@ To initialize the SDK with AWS Credentials use the code below. Note, if you use

```
var apigClient = apigClientFactory.newClient({
invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com',
accessKey: 'ACCESS_KEY',
secretKey: 'SECRET_KEY',
invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED
accessKey: 'ACCESS_KEY', // REQUIRED
secretKey: 'SECRET_KEY', // REQUIRED
sessionToken: 'SESSION_TOKEN', //OPTIONAL: If you are using temporary credentials you must include the session token
region: 'eu-west-1', // OPTIONAL: The region where the API is deployed, by default this parameter is set to us-east-1
region: 'eu-west-1', // REQUIRED: The region where the API is deployed.
systemClockOffset: 0, // OPTIONAL: An offset value in milliseconds to apply to signing time
retries: 4, // OPTIONAL: Number of times to retry before failing. Uses axon-retry plugin.
retryCondition: (err) => { // OPTIONAL: Callback to further control if request should be retried. Uses axon-retry plugin.
Expand All @@ -86,19 +86,8 @@ To use an API Key with the client SDK you can pass the key as a parameter to the

```
var apigClient = apigClientFactory.newClient({
apiKey: 'API_KEY'
invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED
apiKey: 'API_KEY', // REQUIRED
region: 'eu-west-1' // REQUIRED
});
```

# Troubleshooting
The standard Javascript SDK as generated by AWS API Gateway hard codes assertions for your query parameters and headers, which is not possible in this module. Therefore, the params object passed to your `apigClient.invokeApi()` must contain keys that conform exactly to your API definitions.

```
http://example.com/prod?userId=123&info=hello&state=NY
var params = {
userId: '123',
info: 'hello',
state: 'NY'
}
```
5 changes: 1 addition & 4 deletions dist/apigClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
*/
/* eslint max-len: ["error", 100]*/

// import 'babel-polyfill';


var _urlTemplate = require('url-template');

var _urlTemplate2 = _interopRequireDefault(_urlTemplate);
Expand Down Expand Up @@ -51,7 +48,7 @@ apigClientFactory.newClient = function () {
accessKey: '',
secretKey: '',
sessionToken: '',
region: 'us-east-1',
region: '',
apiKey: '',
invokeUrl: '',
service: 'execute-api',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-api-gateway-client",
"version": "0.2.15",
"version": "0.2.16",
"description": "A moduel for AWS API Gateway client",
"repository": {
"type": "git",
Expand Down
4 changes: 1 addition & 3 deletions src/apigClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
/* eslint max-len: ["error", 100]*/

// import 'babel-polyfill';
import uritemplate from 'url-template';
import apiGatewayClientFactory from './lib/apiGatewayCore/apiGatewayClient';

Expand All @@ -35,7 +34,7 @@ apigClientFactory.newClient = (config = {}) => {
accessKey: '',
secretKey: '',
sessionToken: '',
region: 'us-east-1',
region: '',
apiKey: '',
invokeUrl: '',
service: 'execute-api',
Expand Down Expand Up @@ -103,7 +102,6 @@ apigClientFactory.newClient = (config = {}) => {
return apiGatewayClient.makeRequest(request, authType, additionalParams, config.apiKey);
};


return apigClient;
};

Expand Down

0 comments on commit 8e14cf6

Please sign in to comment.