advanced-lambda-context 1.2.13 → 2.1.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.
@@ -0,0 +1,29 @@
1
+ name: publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ concurrency:
8
+ group: release
9
+ cancel-in-progress: false
10
+
11
+ jobs:
12
+ publish:
13
+
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+
19
+ - uses: actions/setup-node@v3
20
+ with:
21
+ node-version: 18.17.0
22
+ cache: npm
23
+
24
+ - name: Dependencies
25
+ run: make install
26
+
27
+ - uses: JS-DevTools/npm-publish@v3
28
+ with:
29
+ token: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,23 @@
1
+ name: test
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ jobs:
7
+ test:
8
+
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+
14
+ - uses: actions/setup-node@v3
15
+ with:
16
+ node-version: 18.17.0
17
+ cache: npm
18
+
19
+ - name: Dependencies
20
+ run: make install
21
+
22
+ - name: Unit Tests
23
+ run: make test
package/Makefile ADDED
@@ -0,0 +1,17 @@
1
+ .PHONY: install test publish
2
+
3
+ ROOT_DIR :=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
4
+ OS := $(shell uname | tr '[:upper:]' '[:lower:]')
5
+
6
+ #
7
+ # Common Repositry Activities
8
+ #
9
+
10
+ install:
11
+ @npm install
12
+
13
+ test:
14
+ @npm test
15
+
16
+ publish:
17
+ @npm publish
package/README.md CHANGED
@@ -16,12 +16,12 @@ npm install bunyan-prettystream-circularsafe --no-save
16
16
  - [ ] generate docs
17
17
  - [ ] publish script
18
18
  - [ ] support alternate serialized config (only supports yml)
19
- - [ ] consider writting in google cloud version
20
- - [ ] consider azure version
19
+ - [x] ~~consider writting in google cloud version~~
20
+ - [x] ~~consider azure version~~
21
21
  - [ ] include event schemas
22
22
  - [ ] write other event parsers as needed
23
23
  - [ ] sqs
24
24
  - [ ] sns -> sqs
25
25
  - [ ] write unit test for ssm.expandParamStoreVariables
26
- - [ ] unhappy path unit test for snsn event parse
26
+ - [ ] unhappy path unit test for sns event parse
27
27
  - [ ] unit tests for 3rd party peer dependencies
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "advanced-lambda-context",
3
- "version": "1.2.13",
3
+ "version": "2.1.0",
4
4
  "description": "A flexible wrapper function for various common lambda use-cases.",
5
5
  "engines": {
6
- "node": ">=14.19.0"
6
+ "node": ">=18.17.0"
7
7
  },
8
8
  "main": "./index.js",
9
9
  "module": "./esm/index.js",
@@ -35,8 +35,7 @@
35
35
  "url": "https://github.com/wambosa/advanced-lambda-context"
36
36
  },
37
37
  "scripts": {
38
- "test": "c8 --exclude **/spec/** --reports-dir ./.build/ jasmine",
39
- "lint": "eslint -c ./config/.eslintrc.yml src"
38
+ "test": "npx c8 --exclude **/spec/** --reports-dir ./.build/ jasmine"
40
39
  },
41
40
  "dependencies": {
42
41
  "argparse": "^1.0.10",
@@ -44,7 +43,7 @@
44
43
  },
45
44
  "devDependencies": {
46
45
  "aws-sdk": "^2.1094.0",
47
- "axios": "^0.26.1",
46
+ "axios": "^1.7.7",
48
47
  "bunyan": "^1.8.12",
49
48
  "bunyan-prettystream-circularsafe": "^0.3.1",
50
49
  "c8": "^7.3.1",
@@ -55,7 +54,7 @@
55
54
  "walk-sync": "^2.0.2"
56
55
  },
57
56
  "peerDependencies": {
58
- "axios": "^0.21.0",
57
+ "axios": "^1.7.7",
59
58
  "bunyan": "^1.8.12",
60
59
  "bunyan-prettystream-circularsafe": "^0.3.1",
61
60
  "serverless-mysql": "^1.5.4",
@@ -8,8 +8,8 @@ describe('GIVEN common environment variables', () => {
8
8
  expect(envVars.path).toBeDefined()
9
9
  })
10
10
 
11
- it('THEN expect NODE_PATH toBe present', () => {
12
- expect(envVars.nodePath).toBeDefined()
11
+ it('THEN expect NVM_DIR toBe present', () => {
12
+ expect(envVars.nvmDir).toBeDefined()
13
13
  })
14
14
  })
15
15
  })
@@ -1,7 +1,9 @@
1
1
  const dataApi = require('./data-api')
2
2
  const mysql = require('./serverless-mysql')
3
+ const sshMysql = require('./ssh-mysql')
3
4
 
4
5
  module.exports = {
5
6
  mysql,
6
7
  dataApi,
8
+ sshMysql,
7
9
  }
@@ -1,4 +1,6 @@
1
1
  import _dataApi from './data-api.js'
2
2
  import _mysql from './serverless-mysql.js'
3
+ import _sshMysql from './ssh-mysql.js'
3
4
  export const dataApi = _dataApi
4
5
  export const mysql = _mysql
6
+ export const sshMysql = _sshMysql
@@ -0,0 +1,40 @@
1
+
2
+ /**
3
+ * SSH MySQL context provider
4
+ *
5
+ * Unlike the regular mysql provider, this supports both getter and setter
6
+ * because SSH MySQL connections require async initialization (SSH handshake + tunnel)
7
+ * and cannot be lazily created synchronously.
8
+ *
9
+ * Usage:
10
+ * .with(sshMysql()) // Default property name: 'sshMysql'
11
+ * .with(sshMysql({ as: 'tunnelDb' })) // Custom property name
12
+ *
13
+ * Then in handler:
14
+ * const db = await createSshConnection(context)
15
+ * context.sshMysql = db.mysql // Setter allows assignment
16
+ * await context.sshMysql.query('SELECT ...') // Getter returns assigned value
17
+ */
18
+ module.exports = (option = {}) => {
19
+ return context => {
20
+ const getterKey = option.as || 'sshMysql'
21
+ const trueKey = `_${getterKey}`
22
+
23
+ if (!context._with[getterKey]) {
24
+ context._with[getterKey] = true
25
+
26
+ Object.defineProperty(context, getterKey, {
27
+ get: function() {
28
+ return this[trueKey]
29
+ },
30
+ set: function(value) {
31
+ this[trueKey] = value
32
+ },
33
+ configurable: true,
34
+ enumerable: true
35
+ })
36
+ }
37
+
38
+ return context
39
+ }
40
+ }