advanced-lambda-context 1.1.1 → 1.2.0
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.js +1 -0
- package/aws/index.mjs +6 -0
- package/index.mjs +3 -0
- package/package.json +34 -11
- package/with/database/data-api.js +33 -0
- package/with/database/database.mjs +4 -0
- package/with/https/axios.mjs +2 -0
- package/with/logger/bunyan.mjs +2 -0
package/aws/index.js
CHANGED
package/aws/index.mjs
ADDED
package/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "advanced-lambda-context",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "A flexible wrapper function for various common lambda use-cases.",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=14.19.0"
|
|
7
7
|
},
|
|
8
8
|
"main": "index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./index.js",
|
|
12
|
+
"import": "./index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./aws": {
|
|
15
|
+
"require": "./aws/index.js",
|
|
16
|
+
"import": "./aws/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"./with/https/axios": {
|
|
19
|
+
"require": "./with/https/axios.js",
|
|
20
|
+
"import": "./with/https/axios.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./with/logger/bunyan": {
|
|
23
|
+
"require": "./with/logger/bunyan.js",
|
|
24
|
+
"import": "./with/logger/bunyan.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./with/database": "./with/database/database.mjs",
|
|
27
|
+
"./with/database/mysql": "./with/database/serverless-mysql.js",
|
|
28
|
+
"./with/database/dataApi": "./with/database/data-api.js",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
9
31
|
"repository": {
|
|
10
32
|
"type": "git",
|
|
11
33
|
"url": "https://github.com/wambosa/advanced-lambda-context"
|
|
12
34
|
},
|
|
13
35
|
"scripts": {
|
|
14
|
-
"publish": "npm publish",
|
|
15
36
|
"test": "c8 --exclude **/spec/** --reports-dir ./.build/ jasmine",
|
|
16
37
|
"lint": "eslint -c ./config/.eslintrc.yml src"
|
|
17
38
|
},
|
|
@@ -20,20 +41,22 @@
|
|
|
20
41
|
"js-yaml": "^3.12.0"
|
|
21
42
|
},
|
|
22
43
|
"devDependencies": {
|
|
23
|
-
"aws-sdk": "^2.
|
|
44
|
+
"aws-sdk": "^2.1094.0",
|
|
45
|
+
"axios": "^0.26.1",
|
|
46
|
+
"bunyan": "^1.8.12",
|
|
47
|
+
"bunyan-prettystream-circularsafe": "^0.3.1",
|
|
24
48
|
"c8": "^7.3.1",
|
|
49
|
+
"data-api-client": "^1.2.0",
|
|
25
50
|
"eslint": "^6.7.2",
|
|
26
51
|
"jasmine": "^3.1.0",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"bunyan": "^1.8.12",
|
|
30
|
-
"bunyan-prettystream-circularsafe": "^0.3.1",
|
|
31
|
-
"serverless-mysql": "^1.5.4"
|
|
52
|
+
"serverless-mysql": "^1.5.4",
|
|
53
|
+
"walk-sync": "^2.0.2"
|
|
32
54
|
},
|
|
33
55
|
"peerDependencies": {
|
|
34
56
|
"axios": "^0.21.0",
|
|
35
57
|
"bunyan": "^1.8.12",
|
|
36
58
|
"bunyan-prettystream-circularsafe": "^0.3.1",
|
|
37
|
-
"serverless-mysql": "^1.5.4"
|
|
59
|
+
"serverless-mysql": "^1.5.4",
|
|
60
|
+
"data-api-client": "^1.2.0"
|
|
38
61
|
}
|
|
39
62
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
library.config({
|
|
15
|
+
host : option.host || this.var.rdsHost,
|
|
16
|
+
database : option.database || this.var.database,
|
|
17
|
+
user : option.user || this.var.rdsUser,
|
|
18
|
+
password : option.pass || this.var.rdsPass
|
|
19
|
+
})
|
|
20
|
+
this[trueKey] = library({
|
|
21
|
+
resourceArn: option.dbArn || this.var.dbArn,
|
|
22
|
+
database: option.dbName || this.var.dbName,
|
|
23
|
+
secretArn: option.secretArn || this.var.secretArn
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
return this[trueKey]
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return context
|
|
32
|
+
}
|
|
33
|
+
}
|