Skip to content

Commit 8e14cf6

Browse files
authored
Merge pull request #63 from kndt84/update-readme
Set region as required param
2 parents 0a13e8e + 4a47954 commit 8e14cf6

File tree

4 files changed

+14
-30
lines changed

4 files changed

+14
-30
lines changed

README.md

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ var apigClient = apigClientFactory.newClient(config);
3333
Calls to an API take the form outlined below. Each API call returns a promise, that invokes either a success and failure callback
3434

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

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

8787
```
8888
var apigClient = apigClientFactory.newClient({
89-
apiKey: 'API_KEY'
89+
invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED
90+
apiKey: 'API_KEY', // REQUIRED
91+
region: 'eu-west-1' // REQUIRED
9092
});
9193
```
92-
93-
# Troubleshooting
94-
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.
95-
96-
```
97-
http://example.com/prod?userId=123&info=hello&state=NY
98-
99-
var params = {
100-
userId: '123',
101-
info: 'hello',
102-
state: 'NY'
103-
}
104-
```

dist/apigClient.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
2020
*/
2121
/* eslint max-len: ["error", 100]*/
2222

23-
// import 'babel-polyfill';
24-
25-
2623
var _urlTemplate = require('url-template');
2724

2825
var _urlTemplate2 = _interopRequireDefault(_urlTemplate);
@@ -51,7 +48,7 @@ apigClientFactory.newClient = function () {
5148
accessKey: '',
5249
secretKey: '',
5350
sessionToken: '',
54-
region: 'us-east-1',
51+
region: '',
5552
apiKey: '',
5653
invokeUrl: '',
5754
service: 'execute-api',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-api-gateway-client",
3-
"version": "0.2.15",
3+
"version": "0.2.16",
44
"description": "A moduel for AWS API Gateway client",
55
"repository": {
66
"type": "git",

src/apigClient.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
/* eslint max-len: ["error", 100]*/
1616

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

@@ -35,7 +34,7 @@ apigClientFactory.newClient = (config = {}) => {
3534
accessKey: '',
3635
secretKey: '',
3736
sessionToken: '',
38-
region: 'us-east-1',
37+
region: '',
3938
apiKey: '',
4039
invokeUrl: '',
4140
service: 'execute-api',
@@ -103,7 +102,6 @@ apigClientFactory.newClient = (config = {}) => {
103102
return apiGatewayClient.makeRequest(request, authType, additionalParams, config.apiKey);
104103
};
105104

106-
107105
return apigClient;
108106
};
109107

0 commit comments

Comments
 (0)