advanced-lambda-context 1.1.3 → 1.2.2

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/aws/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import main from './index.js'
2
+
3
+ export const AwsContext = main.AwsContext
4
+ export const SharedAwsContext = new main.AwsContext()
5
+ export const AwsService = main.AwsService
6
+ export const AwsEvent = main.AwsEvent
package/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import main from './index.js'
2
+
3
+ export default main
package/package.json CHANGED
@@ -1,11 +1,29 @@
1
1
  {
2
2
  "name": "advanced-lambda-context",
3
- "version": "1.1.3",
4
- "description": "",
3
+ "version": "1.2.2",
4
+ "description": "A flexible wrapper function for various common lambda use-cases.",
5
5
  "engines": {
6
- "node": ">=12.16.0"
6
+ "node": ">=14.19.0"
7
7
  },
8
8
  "main": "index.js",
9
+ "exports": {
10
+ "./aws": {
11
+ "require": "./aws/index.js",
12
+ "import": "./aws/index.mjs"
13
+ },
14
+ "./with/https/axios": {
15
+ "require": "./with/https/axios.js",
16
+ "import": "./with/https/axios.mjs"
17
+ },
18
+ "./with/logger/bunyan": {
19
+ "require": "./with/logger/bunyan.js",
20
+ "import": "./with/logger/bunyan.mjs"
21
+ },
22
+ "./with/database": "./with/database/database.mjs",
23
+ "./with/database/mysql": "./with/database/serverless-mysql.js",
24
+ "./with/database/dataApi": "./with/database/data-api.js",
25
+ "./package.json": "./package.json"
26
+ },
9
27
  "repository": {
10
28
  "type": "git",
11
29
  "url": "https://github.com/wambosa/advanced-lambda-context"
@@ -19,20 +37,22 @@
19
37
  "js-yaml": "^3.12.0"
20
38
  },
21
39
  "devDependencies": {
22
- "aws-sdk": "^2.585.0",
40
+ "aws-sdk": "^2.1094.0",
41
+ "axios": "^0.26.1",
42
+ "bunyan": "^1.8.12",
43
+ "bunyan-prettystream-circularsafe": "^0.3.1",
23
44
  "c8": "^7.3.1",
45
+ "data-api-client": "^1.2.0",
24
46
  "eslint": "^6.7.2",
25
47
  "jasmine": "^3.1.0",
26
- "walk-sync": "^2.0.2",
27
- "axios": "^0.21.0",
28
- "bunyan": "^1.8.12",
29
- "bunyan-prettystream-circularsafe": "^0.3.1",
30
- "serverless-mysql": "^1.5.4"
48
+ "serverless-mysql": "^1.5.4",
49
+ "walk-sync": "^2.0.2"
31
50
  },
32
51
  "peerDependencies": {
33
52
  "axios": "^0.21.0",
34
53
  "bunyan": "^1.8.12",
35
54
  "bunyan-prettystream-circularsafe": "^0.3.1",
36
- "serverless-mysql": "^1.5.4"
55
+ "serverless-mysql": "^1.5.4",
56
+ "data-api-client": "^1.2.0"
37
57
  }
38
58
  }
@@ -0,0 +1,27 @@
1
+
2
+ module.exports = (option = { }) => {
3
+ return context => {
4
+ const getterKey = option.as || 'dataApi'
5
+ const trueKey = `_${getterKey}`
6
+
7
+ if (!context._with[getterKey]) {
8
+ context._with[getterKey] = true
9
+
10
+ Object.defineProperty(context, getterKey, {
11
+ get: function() {
12
+ if (!this[trueKey]) {
13
+ let library = option.library || require('data-api-client')
14
+ this[trueKey] = library({
15
+ resourceArn: option.dbArn || this.var.dbArn,
16
+ database: option.dbName || this.var.dbName,
17
+ secretArn: option.secretArn || this.var.secretArn
18
+ })
19
+ }
20
+ return this[trueKey]
21
+ }
22
+ })
23
+ }
24
+
25
+ return context
26
+ }
27
+ }
@@ -0,0 +1,4 @@
1
+ import _dataApi from './data-api.js'
2
+ import _mysql from './serverless-mysql.js'
3
+ export const dataApi = _dataApi
4
+ export const mysql = _mysql
@@ -0,0 +1,2 @@
1
+ import main from './axios.js'
2
+ export default main
@@ -0,0 +1,2 @@
1
+ import main from './bunyan.js'
2
+ export default main