node-lambda 1.2.1 → 2.0.0-alpha.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.
@@ -29,7 +29,7 @@ jobs:
29
29
 
30
30
  # Initializes the CodeQL tools for scanning.
31
31
  - name: Initialize CodeQL
32
- uses: github/codeql-action/init@v2
32
+ uses: github/codeql-action/init@v3
33
33
  with:
34
34
  languages: ${{ matrix.language }}
35
35
  # If you wish to specify custom queries, you can do so here or in a config file.
@@ -40,7 +40,7 @@ jobs:
40
40
  # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
41
41
  # If this step fails, then you should remove it and run the build manually (see below)
42
42
  - name: Autobuild
43
- uses: github/codeql-action/autobuild@v2
43
+ uses: github/codeql-action/autobuild@v3
44
44
 
45
45
  # ℹ️ Command-line programs to run using the OS shell.
46
46
  # 📚 https://git.io/JvXDl
@@ -54,4 +54,4 @@ jobs:
54
54
  # make release
55
55
 
56
56
  - name: Perform CodeQL Analysis
57
- uses: github/codeql-action/analyze@v2
57
+ uses: github/codeql-action/analyze@v3
@@ -9,7 +9,7 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- node-version: [16.x, 18.x, 20.x]
12
+ node-version: [20.x, 22.x]
13
13
  steps:
14
14
  - uses: actions/checkout@v4
15
15
  - uses: actions/setup-node@v4
@@ -32,7 +32,7 @@ jobs:
32
32
  - uses: actions/checkout@v4
33
33
  - uses: actions/setup-node@v4
34
34
  with:
35
- node-version: 20.x
35
+ node-version: 22.x
36
36
  cache: 'npm'
37
37
  - run: node -v
38
38
  - run: npm -v
package/CHANGELOG.md CHANGED
@@ -480,3 +480,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
480
480
  - Improve testing
481
481
  - Update dependencies
482
482
  - Update README
483
+
484
+ ## [1.3.0] - 2024-01-04
485
+ ### Features
486
+ - Support .mjs [#701](https://github.com/motdotla/node-lambda/pull/701)
487
+ - Update lambda runtime list [#702](https://github.com/motdotla/node-lambda/pull/702)
488
+
489
+ ### Minor changes
490
+ - Update dependencies
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- If you found this useful, consider also checking out [dotenv-vault](https://github.com/dotenv-org/dotenv-vault). Thank you! 😇
1
+ > If you found this useful, consider also checking out [dotenvx](https://github.com/dotenvx/dotenvx). Thank you! 😇
2
2
 
3
3
  # node-lambda
4
4
 
@@ -230,7 +230,7 @@ AWS Lambda will let you set environment variables for your function. Use the sam
230
230
 
231
231
  ## Node.js Runtime Configuration
232
232
 
233
- AWS Lambda now supports Node.js 18, Node.js 16 and Node.js 14. Please also check the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) page.
233
+ AWS Lambda now supports Node.js 20, Node.js 18 and Node.js 16. Please also check the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) page.
234
234
 
235
235
  ## Use S3 to deploy
236
236
 
package/bin/node-lambda CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  'use strict'
4
4
 
5
- require('dotenv').config()
5
+ require('@dotenvx/dotenvx').config()
6
6
  const process = require('process')
7
7
  const path = require('path')
8
8
 
package/index_mjs.mjs ADDED
@@ -0,0 +1,9 @@
1
+ // For development/testing purposes
2
+ export const handler = (event, context, callback) => {
3
+ console.log('Running index.handler (mjs)')
4
+ console.log('==================================')
5
+ console.log('event', event)
6
+ console.log('==================================')
7
+ console.log('Stopping index.handler (mjs)')
8
+ callback(null)
9
+ }
package/lib/.env.example CHANGED
@@ -10,10 +10,11 @@ AWS_HANDLER=index.handler
10
10
  AWS_MEMORY_SIZE=128
11
11
  AWS_TIMEOUT=3
12
12
  AWS_DESCRIPTION=
13
- AWS_RUNTIME=nodejs18.x
13
+ AWS_RUNTIME=nodejs20.x
14
14
  AWS_VPC_SUBNETS=
15
15
  AWS_VPC_SECURITY_GROUPS=
16
16
  AWS_TRACING_CONFIG=
17
17
  AWS_LOGS_RETENTION_IN_DAYS=
18
18
  EXCLUDE_GLOBS="event.json build/"
19
+ CONFIG_FILE="deploy.env"
19
20
  PACKAGE_DIRECTORY=build
package/lib/aws.js CHANGED
@@ -1,38 +1,41 @@
1
- 'use strict'
2
-
3
- const aws = require('aws-sdk')
4
- const proxy = require('proxy-agent')
5
-
6
- module.exports = {
7
- sdk: aws,
8
- updateConfig (config, region) {
9
- const awsSecurity = { region }
10
-
11
- if (config.profile) {
12
- aws.config.credentials = new aws.SharedIniFileCredentials({
13
- profile: config.profile
14
- })
15
- } else {
16
- awsSecurity.accessKeyId = config.accessKey
17
- awsSecurity.secretAccessKey = config.secretKey
18
- }
19
-
20
- if (config.sessionToken) {
21
- awsSecurity.sessionToken = config.sessionToken
22
- }
23
-
24
- if (config.deployTimeout) {
25
- aws.config.httpOptions.timeout = parseInt(config.deployTimeout)
26
- }
27
-
28
- if (config.proxy) {
29
- aws.config.httpOptions.agent = proxy(config.proxy)
30
- }
31
-
32
- if (config.endpoint) {
33
- aws.config.endpoint = config.endpoint
34
- }
35
-
36
- aws.config.update(awsSecurity)
37
- }
38
- }
1
+ // TODO:
2
+ // Support these option settings in SDK v3
3
+ //
4
+ // 'use strict'
5
+ //
6
+ // const aws = require('aws-sdk')
7
+ // const proxy = require('proxy-agent')
8
+ //
9
+ // module.exports = {
10
+ // sdk: aws,
11
+ // updateConfig (config, region) {
12
+ // const awsSecurity = { region }
13
+ //
14
+ // if (config.profile) {
15
+ // aws.config.credentials = new aws.SharedIniFileCredentials({
16
+ // profile: config.profile
17
+ // })
18
+ // } else {
19
+ // awsSecurity.accessKeyId = config.accessKey
20
+ // awsSecurity.secretAccessKey = config.secretKey
21
+ // }
22
+ //
23
+ // if (config.sessionToken) {
24
+ // awsSecurity.sessionToken = config.sessionToken
25
+ // }
26
+ //
27
+ // if (config.deployTimeout) {
28
+ // aws.config.httpOptions.timeout = parseInt(config.deployTimeout)
29
+ // }
30
+ //
31
+ // if (config.proxy) {
32
+ // aws.config.httpOptions.agent = proxy(config.proxy)
33
+ // }
34
+ //
35
+ // if (config.endpoint) {
36
+ // aws.config.endpoint = config.endpoint
37
+ // }
38
+ //
39
+ // aws.config.update(awsSecurity)
40
+ // }
41
+ // }
@@ -1,15 +1,14 @@
1
1
  'use strict'
2
2
 
3
+ const {
4
+ CloudWatchLogsClient,
5
+ CreateLogGroupCommand,
6
+ PutRetentionPolicyCommand
7
+ } = require('@aws-sdk/client-cloudwatch-logs')
8
+
3
9
  class CloudWatchLogs {
4
- constructor (aws, region) {
5
- // Authenticated `aws` object in `lib/main.js`
6
- this.lambda = new aws.Lambda({
7
- region,
8
- apiVersion: '2015-03-31'
9
- })
10
- this.cloudwatchlogs = new aws.CloudWatchLogs({
11
- apiVersion: '2014-03-28'
12
- })
10
+ constructor (config) {
11
+ this.client = new CloudWatchLogsClient(config)
13
12
  }
14
13
 
15
14
  _logGroupName (params) {
@@ -17,33 +16,24 @@ class CloudWatchLogs {
17
16
  }
18
17
 
19
18
  _createLogGroup (params) {
20
- return new Promise((resolve, reject) => {
21
- this.cloudwatchlogs.createLogGroup({
19
+ try {
20
+ return this.client.send(new CreateLogGroupCommand({
22
21
  logGroupName: this._logGroupName(params)
23
- }, (err, data) => {
24
- if (err) {
25
- if (err.code === 'ResourceAlreadyExistsException') {
26
- // If it exists it will result in an error but there is no problem.
27
- return resolve({})
28
- }
29
- return reject(err)
30
- }
31
-
32
- resolve(data)
33
- })
34
- })
22
+ }))
23
+ } catch (err) {
24
+ if (err.code === 'ResourceAlreadyExistsException') {
25
+ // If it exists it will result in an error but there is no problem.
26
+ return {}
27
+ }
28
+ throw err
29
+ }
35
30
  }
36
31
 
37
32
  _putRetentionPolicy (params) {
38
- return new Promise((resolve, reject) => {
39
- this.cloudwatchlogs.putRetentionPolicy({
40
- logGroupName: this._logGroupName(params),
41
- retentionInDays: params.retentionInDays
42
- }, (err, data) => {
43
- if (err) return reject(err)
44
- resolve(data)
45
- })
46
- })
33
+ return this.client.send(new PutRetentionPolicyCommand({
34
+ logGroupName: this._logGroupName(params),
35
+ retentionInDays: params.retentionInDays
36
+ }))
47
37
  }
48
38
 
49
39
  setLogsRetentionPolicy (params) {