-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial draft, still need to move most of the services over
- Loading branch information
1 parent
41ef646
commit d5b563c
Showing
5 changed files
with
190 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
let cache = {}; | ||
|
||
const secrets = require("./lib/secretsmanager"); | ||
const dynamodb = require("./lib/dynamodb"); | ||
|
||
function build(configuration) { | ||
return { | ||
secrets: secrets(configuration), | ||
dynamodb: dynamodb(configuration) | ||
}; | ||
} | ||
|
||
module.exports = function(configuration, forceNew = false) { | ||
let c = JSON.stringify(configuration); | ||
|
||
if (!(c in cache) || forceNew) { | ||
cache[c] = build(configuration); | ||
} | ||
return cache[c]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
var AWS = require('aws-sdk'); | ||
var https = require("https"); | ||
let extend = require("extend"); | ||
const async = require("async"); | ||
|
||
// AWS.config.logger = console; | ||
|
||
module.exports = function(configuration) { | ||
configuration = Object.assign({ | ||
maxRetries: 2, | ||
convertEmptyValues: true, | ||
httpOptions: { | ||
connectTimeout: 2000, | ||
timeout: 5000, | ||
agent: new https.Agent({ | ||
ciphers: 'ALL', | ||
secureProtocol: 'TLSv1_method', | ||
// keepAlive: true | ||
}) | ||
} | ||
}, | ||
configuration || {}); | ||
var docClient = new AWS.DynamoDB.DocumentClient(configuration); | ||
return { | ||
_service: docClient, | ||
get: function(table, id, opts = {}) { | ||
return docClient.get({ | ||
TableName: table, | ||
Key: { | ||
[opts.id || 'id']: id | ||
}, | ||
ConsistentRead: true, | ||
"ReturnConsumedCapacity": 'TOTAL' | ||
}).promise().then(data => data.Item); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters