presidium 0.29.10 → 0.29.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AwsCredentials.js CHANGED
@@ -24,6 +24,17 @@ const pathResolve = require('./internal/pathResolve')
24
24
  */
25
25
 
26
26
  const AwsCredentials = async function (options = {}) {
27
+ if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) {
28
+ const awsCreds = {
29
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
30
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
31
+ }
32
+ if (process.env.AWS_REGION) {
33
+ awsCreds.region = process.env.AWS_REGION
34
+ }
35
+ return awsCreds
36
+ }
37
+
27
38
  const profile = (
28
39
  typeof options == 'string' ? options : options.profile
29
40
  ) ?? 'default'
@@ -35,6 +35,24 @@ aws_secret_access_key = FFF
35
35
  assert.equal(awsCreds.secretAccessKey, 'FFF')
36
36
  }
37
37
 
38
+ {
39
+ process.env.AWS_ACCESS_KEY_ID = 'AA2'
40
+ process.env.AWS_SECRET_ACCESS_KEY = 'FF2'
41
+ const awsCreds = await AwsCredentials()
42
+ assert.equal(awsCreds.accessKeyId, 'AA2')
43
+ assert.equal(awsCreds.secretAccessKey, 'FF2')
44
+ }
45
+
46
+ {
47
+ process.env.AWS_ACCESS_KEY_ID = 'AA2'
48
+ process.env.AWS_SECRET_ACCESS_KEY = 'FF2'
49
+ process.env.AWS_REGION = 'us-east-2'
50
+ const awsCreds = await AwsCredentials()
51
+ assert.equal(awsCreds.accessKeyId, 'AA2')
52
+ assert.equal(awsCreds.secretAccessKey, 'FF2')
53
+ assert.equal(awsCreds.region, 'us-east-2')
54
+ }
55
+
38
56
  await fs.promises.rm(`${__dirname}/../.aws`, { recursive: true })
39
57
  }).case()
40
58
 
package/Dependency.js CHANGED
@@ -39,6 +39,9 @@ Dependency.teardown = async function teardown(dependency) {
39
39
  dependency.close()
40
40
  await dependency.delete()
41
41
  }
42
+ else if (typeof dependency.destroy == 'function') {
43
+ await dependency.destroy()
44
+ }
42
45
 
43
46
  dependency?.timers?.forEach(clearInterval)
44
47
  }
@@ -1,4 +1,5 @@
1
1
  const Test = require('thunk-test')
2
+ const assert = require('assert')
2
3
  const DynamoTable = require('./DynamoTable')
3
4
  const DynamoStream = require('./DynamoStream')
4
5
  const ElasticsearchIndex = require('./ElasticsearchIndex')
@@ -48,12 +49,22 @@ const test = new Test('Dependency.teardown', async function () {
48
49
  })
49
50
  await myKinesisStream.ready
50
51
 
52
+ let didDestroyMyCache = false
53
+ const myCache = {
54
+ destroy() {
55
+ didDestroyMyCache = true
56
+ }
57
+ }
58
+
51
59
  await Dependency.teardown(null)
52
60
  await Dependency.teardown(myDynamoTable)
53
61
  await Dependency.teardown(myDynamoStream)
54
62
  await Dependency.teardown(myElasticsearchIndex)
55
63
  await Dependency.teardown(myS3Bucket)
56
64
  await Dependency.teardown(myKinesisStream)
65
+ await Dependency.teardown(myCache)
66
+ assert(didDestroyMyCache)
67
+
57
68
  }).case()
58
69
 
59
70
  if (process.argv[1] == __filename) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.29.10",
3
+ "version": "0.29.12",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",