You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.js
+21-14Lines changed: 21 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,19 @@ module.exports = Dyno;
6
6
7
7
/**
8
8
* Creates a dyno client. You must provide a table name and the region where the
9
-
* table resides. Where applicable, dyno will use this table as the default in
10
-
* your requests. However you can override this when constructing any individual
11
-
* request.
9
+
* table resides. Region can be supplied with either the `region` option, or as
10
+
* a property on the `awsConfig` option. Where applicable, dyno will use this
11
+
* table as the default in your requests. However you can override this when
12
+
* constructing any individual request.
12
13
*
13
14
* If you do not explicitly pass credentials when creating a dyno client, the
14
15
* aws-sdk will look for credentials in a variety of places. See [the configuration guide](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html)
* @param {string} options.table - the name of the table to interact with by default
19
-
* @param {string} options.region - the region in which the default table resides
20
+
* @param {object} [options.awsConfig] - an instance of AWS.Config to use in lieu of setting individual options. See [AWS.Config docs for details](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html)
21
+
* @param {string} [options.region] - the region in which the default table resides
20
22
* @param {string} [options.endpoint] - the dynamodb endpoint url
21
23
* @param {object} [options.httpOptions] - httpOptions to provide the aws-sdk client. See [constructor docs for details](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#constructor-property).
22
24
* @param {string} [options.accessKeyId] - credentials for the client to utilize
@@ -60,20 +62,25 @@ function Dyno(options) {
60
62
*/
61
63
62
64
if(!options.table)thrownewError('table is required');// Demand table be specified
63
-
if(!options.region)thrownewError('region is required');
64
65
65
66
varconfig={
66
-
region: options.region,
67
-
endpoint: options.endpoint,
68
-
params: {TableName: options.table},// Sets `TableName` in every request
69
-
httpOptions: options.httpOptions||{timeout: 5000},// Default appears to be 2 min
70
-
accessKeyId: options.accessKeyId,
71
-
secretAccessKey: options.secretAccessKey,
72
-
sessionToken: options.sessionToken,
73
-
logger: options.logger,
74
-
maxRetries: options.maxRetries
67
+
params: {
68
+
TableName: options.table// Sets `TableName` in every request
69
+
},
70
+
httpOptions: {
71
+
timeout: 5000// Default appears to be 2 min
72
+
}
75
73
};
76
74
75
+
if(!options.awsConfig){
76
+
if(!options.region)thrownewError('region is required');
0 commit comments