Skip to content

Commit b933e07

Browse files
authored
Add nodejs16.x runtime (#14)
1 parent 937c9cf commit b933e07

11 files changed

+65
-62
lines changed

.github/workflows/CI.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515

16-
- uses: actions/setup-node@v2
16+
- uses: actions/setup-node@v3
1717
with:
18-
node-version: '12'
18+
node-version: '14'
1919
cache: 'yarn'
2020

2121
- name: Install dependencies
@@ -25,7 +25,7 @@ jobs:
2525
run: yarn build
2626

2727
- name: Upload build artifact
28-
uses: actions/upload-artifact@v2
28+
uses: actions/upload-artifact@v3
2929
with:
3030
name: dist
3131
path: dist/
@@ -46,11 +46,11 @@ jobs:
4646
brew install aws-sam-cli
4747
sam --version
4848
49-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v3
5050

51-
- uses: actions/setup-node@v2
51+
- uses: actions/setup-node@v3
5252
with:
53-
node-version: '12'
53+
node-version: '14'
5454
cache: 'yarn'
5555

5656
- name: Install dependencies
@@ -68,14 +68,14 @@ jobs:
6868
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6969

7070
steps:
71-
- uses: actions/checkout@v2
71+
- uses: actions/checkout@v3
7272
with:
7373
fetch-depth: 25
7474

7575
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
7676

7777
- name: Download build artifact
78-
uses: actions/download-artifact@v2
78+
uses: actions/download-artifact@v3
7979
with:
8080
name: dist
8181
path: dist

.github/workflows/lint.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
1616

1717
- name: Setup node
18-
uses: actions/setup-node@v2
18+
uses: actions/setup-node@v3
1919
with:
20-
node-version: '12'
20+
node-version: '14'
2121
cache: 'yarn'
2222

2323
- name: Install Dependencies

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const lambdaSAM = await generateAPISAM({
4141
first: {
4242
filename: 'lambda.zip',
4343
handler: 'handler.handler',
44-
runtime: 'nodejs14.x',
44+
runtime: 'nodejs16.x',
4545
route: '/test',
4646
method: 'get',
4747
},

lib/SAMTemplate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const defaultFunctionProperties: Pick<
2222
PartialServerLessFunctionProps
2323
> = {
2424
MemorySize: 128, // in mb
25-
Runtime: 'nodejs14.x',
25+
Runtime: 'nodejs16.x',
2626
Timeout: 30, // in seconds
2727
};
2828

lib/generateProxyModel.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import * as path from 'path';
21
import * as fs from 'fs';
3-
import { dirSync as tmpDir } from 'tmp';
4-
import { stringify as yaml } from 'yaml';
5-
import { Lambda as AWSLambda } from 'aws-sdk';
2+
import { createServer } from 'http';
3+
import * as path from 'path';
4+
import { URL } from 'url';
5+
66
import {
77
CloudFrontRequest,
88
CloudFrontRequestEvent,
99
CloudFrontResultResponse,
1010
} from 'aws-lambda';
11+
import { Lambda as AWSLambda } from 'aws-sdk';
1112
import getPort from 'get-port';
12-
import http from 'http';
13-
import { URL } from 'url';
13+
import { dirSync as tmpDir } from 'tmp';
14+
import { stringify as yaml } from 'yaml';
1415

1516
import { SAMLocalLambadCLIOptions, SAMTemplate } from './types';
1617
import { getLocalIpAddressFromHost, unzipToLocation } from './utils';
@@ -26,7 +27,7 @@ const LambdaFunctionName = 'proxy';
2627
interface Props {
2728
pathToProxyPackage: string;
2829
proxyConfig: string;
29-
runtime?: 'nodejs12.x' | 'nodejs14.x';
30+
runtime?: 'nodejs12.x' | 'nodejs14.x' | 'nodejs16.x';
3031
onData?: (data: any) => void;
3132
onError?: (data: any) => void;
3233
cliOptions?: SAMLocalLambadCLIOptions;
@@ -93,7 +94,7 @@ export async function generateProxySAM({
9394
let portProxyConfig: number;
9495
// Simple HTTP server to serve the proxy config
9596
// https://stackoverflow.com/a/44188852/831465
96-
const serverProxyConfig = http.createServer((_req, res) => {
97+
const serverProxyConfig = createServer((_req, res) => {
9798
res.writeHead(200);
9899
res.end(proxyConfig);
99100
});

lib/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
type LambdaRuntime = 'nodejs12.x' | 'nodejs14.x' | 'nodejs16.x';
2+
13
export interface ServerLessFunctionAPIEvent {
24
Type: 'Api' | 'HttpApi';
35
Properties: {
@@ -12,7 +14,7 @@ export interface ServerLessFunction {
1214
Type: 'AWS::Serverless::Function';
1315
Properties: {
1416
Handler: string;
15-
Runtime: 'nodejs12.x' | 'nodejs14.x';
17+
Runtime: LambdaRuntime;
1618
MemorySize: number;
1719
Timeout: number;
1820
Description?: string;
@@ -34,7 +36,7 @@ export interface SAMTemplate {
3436

3537
export interface ConfigLambda {
3638
handler: string;
37-
runtime: 'nodejs12.x' | 'nodejs14.x';
39+
runtime: LambdaRuntime;
3840
filename: string;
3941
route?: string;
4042
routes?: Record<string, string>;

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"fix:prettier": "prettier --write ."
1515
},
1616
"dependencies": {
17-
"aws-sdk": "^2.804.0",
17+
"aws-sdk": "^2.1055.0",
1818
"change-case": "^4.1.2",
1919
"get-port": "^5.1.1",
2020
"node-fetch": "^2.6.7",
@@ -23,16 +23,16 @@
2323
"yaml": "^1.10.0"
2424
},
2525
"devDependencies": {
26-
"@tsconfig/node12": "^1.0.9",
27-
"@types/archiver": "^5.1.1",
26+
"@tsconfig/node14": "^1.0.1",
27+
"@types/archiver": "^5.3.1",
2828
"@types/aws-lambda": "^8.10.71",
2929
"@types/jest": "^27.0.1",
3030
"@types/node": "^12.0.0",
3131
"@types/node-fetch": "^2.5.8",
3232
"@types/rimraf": "^3.0.2",
3333
"@types/tmp": "^0.2.0",
3434
"@types/unzipper": "^0.10.3",
35-
"archiver": "^5.3.0",
35+
"archiver": "^5.3.1",
3636
"jest": "^27.1.0",
3737
"prettier": "^2.2.1",
3838
"rimraf": "^3.0.2",
@@ -43,6 +43,6 @@
4343
"dist/**/*"
4444
],
4545
"engines": {
46-
"node": ">=12.0.0"
46+
"node": ">=14.0.0"
4747
}
4848
}

test/api-gateway.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from 'fs';
22
import * as os from 'os';
33
import * as path from 'path';
44

5-
import rimraf from 'rimraf';
5+
import { sync as rimrafSync } from 'rimraf';
66

77
import { APISAMGenerator } from '../lib/index';
88
import { generateAPISAM } from '../lib/index';
@@ -30,7 +30,7 @@ describe('integration:Api-Gateway', () => {
3030
first: {
3131
filename: 'first.zip',
3232
handler: 'handler.handler',
33-
runtime: 'nodejs14.x',
33+
runtime: 'nodejs16.x',
3434
route,
3535
method: 'get',
3636
},
@@ -48,7 +48,7 @@ describe('integration:Api-Gateway', () => {
4848

4949
afterAll(async () => {
5050
await lambdaSAM.stop();
51-
rimraf.sync(tmpdir);
51+
rimrafSync(tmpdir);
5252
});
5353

5454
test('Invoke through API Gateway', async () => {

test/event.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from 'fs';
22
import * as os from 'os';
33
import * as path from 'path';
44

5-
import rimraf from 'rimraf';
5+
import { sync as rimrafSync } from 'rimraf';
66

77
import { LocalSAMGenerator } from '../lib/index';
88
import { generateLocalSAM } from '../lib/index';
@@ -30,7 +30,7 @@ describe('integration:Event', () => {
3030
[functionName]: {
3131
filename: 'first.zip',
3232
handler: 'handler.handler',
33-
runtime: 'nodejs14.x',
33+
runtime: 'nodejs16.x',
3434
},
3535
},
3636
cwd: tmpdir,
@@ -47,7 +47,7 @@ describe('integration:Event', () => {
4747

4848
afterAll(async () => {
4949
await lambdaSAM.stop();
50-
rimraf.sync(tmpdir);
50+
rimrafSync(tmpdir);
5151
});
5252

5353
test('Invoke through AWS SDK', async () => {

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "@tsconfig/node12/tsconfig.json",
2+
"extends": "@tsconfig/node14/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "dist",
55
"declaration": true

yarn.lock

+26-26
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,15 @@
506506
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
507507
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
508508

509-
"@tsconfig/node12@^1.0.9":
510-
version "1.0.9"
511-
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c"
512-
integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==
509+
"@tsconfig/node14@^1.0.1":
510+
version "1.0.1"
511+
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2"
512+
integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==
513513

514-
"@types/archiver@^5.1.1":
515-
version "5.1.1"
516-
resolved "https://registry.yarnpkg.com/@types/archiver/-/archiver-5.1.1.tgz#d6d7610de4386b293abd5c1cb1875e0a4f4e1c30"
517-
integrity sha512-heuaCk0YH5m274NOLSi66H1zX6GtZoMsdE6TYFcpFFjBjg0FoU4i4/M/a/kNlgNg26Xk3g364mNOYe1JaiEPOQ==
514+
"@types/archiver@^5.3.1":
515+
version "5.3.1"
516+
resolved "https://registry.yarnpkg.com/@types/archiver/-/archiver-5.3.1.tgz#02991e940a03dd1a32678fead4b4ca03d0e387ca"
517+
integrity sha512-wKYZaSXaDvTZuInAWjCeGG7BEAgTWG2zZW0/f7IYFcoHB2X2d9lkVFnrOlXl3W6NrvO6Ml3FLLu8Uksyymcpnw==
518518
dependencies:
519519
"@types/glob" "*"
520520

@@ -753,13 +753,13 @@ archiver-utils@^2.1.0:
753753
normalize-path "^3.0.0"
754754
readable-stream "^2.0.0"
755755

756-
archiver@^5.3.0:
757-
version "5.3.0"
758-
resolved "https://registry.yarnpkg.com/archiver/-/archiver-5.3.0.tgz#dd3e097624481741df626267564f7dd8640a45ba"
759-
integrity sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==
756+
archiver@^5.3.1:
757+
version "5.3.1"
758+
resolved "https://registry.yarnpkg.com/archiver/-/archiver-5.3.1.tgz#21e92811d6f09ecfce649fbefefe8c79e57cbbb6"
759+
integrity sha512-8KyabkmbYrH+9ibcTScQ1xCJC/CGcugdVIwB+53f5sZziXgwUh3iXlAlANMxcZyDEfTHMe6+Z5FofV8nopXP7w==
760760
dependencies:
761761
archiver-utils "^2.1.0"
762-
async "^3.2.0"
762+
async "^3.2.3"
763763
buffer-crc32 "^0.2.1"
764764
readable-stream "^3.6.0"
765765
readdir-glob "^1.0.0"
@@ -773,25 +773,25 @@ argparse@^1.0.7:
773773
dependencies:
774774
sprintf-js "~1.0.2"
775775

776-
async@^3.2.0:
777-
version "3.2.1"
778-
resolved "https://registry.yarnpkg.com/async/-/async-3.2.1.tgz#d3274ec66d107a47476a4c49136aacdb00665fc8"
779-
integrity sha512-XdD5lRO/87udXCMC9meWdYiR+Nq6ZjUfXidViUZGu2F1MO4T3XwZ1et0hb2++BgLfhyJwy44BGB/yx80ABx8hg==
776+
async@^3.2.3:
777+
version "3.2.3"
778+
resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9"
779+
integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==
780780

781781
asynckit@^0.4.0:
782782
version "0.4.0"
783783
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
784784
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
785785

786-
aws-sdk@^2.804.0:
787-
version "2.884.0"
788-
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.884.0.tgz#dd82338bb2c26201c59ac799abec3d6db51cbe21"
789-
integrity sha512-+rhzq7zmntsj4VJRUf0v6ri9vw3dYroy9BbRtbxLHILdnSFPkoqMcodr/pwcUSO5kYEYbCG7mxr5/R2a+cfbxQ==
786+
aws-sdk@^2.1055.0:
787+
version "2.1139.0"
788+
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1139.0.tgz#8800d6cff33663f5d226f1cc51cdd83bd46d7ffe"
789+
integrity sha512-aLmdIhIQuOdbf6F/QJCHm3xfr+9Esh9vWxZmOi54iEOcfHuO48VEEfa2A6NXb2JmUtWGB5AX80ssp6F90bhA6g==
790790
dependencies:
791791
buffer "4.9.2"
792792
events "1.1.1"
793793
ieee754 "1.1.13"
794-
jmespath "0.15.0"
794+
jmespath "0.16.0"
795795
querystring "0.2.0"
796796
sax "1.2.1"
797797
url "0.10.3"
@@ -2127,10 +2127,10 @@ jest@^27.1.0:
21272127
import-local "^3.0.2"
21282128
jest-cli "^27.1.0"
21292129

2130-
jmespath@0.15.0:
2131-
version "0.15.0"
2132-
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217"
2133-
integrity sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=
2130+
jmespath@0.16.0:
2131+
version "0.16.0"
2132+
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076"
2133+
integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==
21342134

21352135
js-tokens@^4.0.0:
21362136
version "4.0.0"

0 commit comments

Comments
 (0)