Skip to content

Commit 3eb9a39

Browse files
committed
feat: update node version 18
BREAKING CHANGE: - node version >= 18 required - APIGatewayProxyHandler body mandatory response field
1 parent e6bd63f commit 3eb9a39

File tree

15 files changed

+10217
-7995
lines changed

15 files changed

+10217
-7995
lines changed

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint && npm run test -- -b

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
"verbose": true,
3+
"preset": "ts-jest",
4+
"testEnvironment": "node",
5+
"coverageDirectory": "test-reports",
6+
"roots": [
7+
"src"
8+
],
9+
"reporters": [
10+
"default",
11+
["jest-junit", {
12+
"outputDirectory": "test-reports/jest",
13+
"outputName": "report.xml"
14+
}]
15+
]
16+
};

package-lock.json

Lines changed: 10108 additions & 7898 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
"description": "An opinionated Typescript package that facilitates specifying AWS Lambda handlers including input validation, error handling and response formatting.",
55
"main": "index.js",
66
"types": "index.d.ts",
7+
"engines": {
8+
"node": ">=18"
9+
},
710
"scripts": {
811
"lint": "eslint './src/**/*.ts'",
9-
"test": "NODE_ENV=testing jest -b --reporters jest-dot-reporter",
12+
"test": "NODE_ENV=testing jest --detectOpenHandles --no-cache -b --reporters jest-progress-bar-reporter",
1013
"test:verbose": "npm run test -- --reporters default",
1114
"test:coverage": "npm run test -- --coverage",
1215
"test:coverage:verbose": "npm run test:coverage -- --reporters default",
1316
"test:ci": "npm run test:coverage:verbose -- --ci",
1417
"build": "npm run clean && npm run build:compile && npm run build:copy",
1518
"build:compile": "tsc -p tsconfig.build.json",
1619
"build:copy": "cp LICENSE README.md package.json dist/",
17-
"clean": "rimraf ./dist"
20+
"clean": "rimraf ./dist",
21+
"prepare": "[ ! -x ./node_modules/.bin/husky ] && exit 0; husky install"
1822
},
1923
"repository": {
2024
"type": "git",
@@ -27,53 +31,35 @@
2731
],
2832
"author": "Steffen Leistner",
2933
"contributors": [
30-
"Martin Pirkl <[email protected]>"
34+
"Martin Pirkl <[email protected]>",
35+
"Steve Waldowski <[email protected]>"
3136
],
3237
"license": "Apache-2.0",
3338
"bugs": {
3439
"url": "https://github.com/enter-at/node-aws-lambda-handlers/issues"
3540
},
3641
"homepage": "https://github.com/enter-at/node-aws-lambda-handlers#readme",
37-
"dependencies": {},
3842
"devDependencies": {
39-
"@enter-at/eslint-config-typescript-prettier": "1.5.2",
40-
"@types/aws-lambda": "8.10.76",
43+
"@enter-at/eslint-config-typescript-prettier": "1.6.0",
44+
"@faker-js/faker": "7.6.0",
45+
"@tsconfig/node18": "1.0.1",
46+
"@types/aws-lambda": "8.10.109",
4147
"@types/aws-sdk": "2.7.0",
42-
"@types/faker": "4.1.12",
43-
"@types/jest": "26.0.24",
48+
"@types/jest": "29.2.4",
4449
"aws-lambda": "1.0.7",
45-
"eslint": "7.32.0",
46-
"aws-sdk": "2.1087.0",
47-
"faker": "4.1.0",
48-
"husky": "4.3.8",
49-
"jest": "26.6.3",
50-
"jest-dot-reporter": "1.0.14",
51-
"jest-junit": "11.1.0",
52-
"prettier": "2.2.1",
50+
"aws-sdk": "2.1277.0",
51+
"eslint": "8.30.0",
52+
"husky": "8.0.2",
53+
"jest": "29.3.1",
54+
"jest-junit": "15.0.0",
55+
"jest-progress-bar-reporter": "1.0.25",
56+
"prettier": "2.8.1",
5357
"rimraf": "3.0.2",
54-
"ts-jest": "26.5.6",
55-
"typescript": "3.9.10"
56-
},
57-
"jest": {
58-
"verbose": true,
59-
"preset": "ts-jest",
60-
"testEnvironment": "node",
61-
"coverageDirectory": "test-reports",
62-
"roots": [
63-
"src"
64-
],
65-
"reporters": [
66-
"default",
67-
"jest-junit"
68-
]
58+
"ts-jest": "29.0.3",
59+
"typescript": "4.9.4"
6960
},
7061
"jest-junit": {
7162
"outputDirectory": "test-reports/jest",
7263
"outputName": "report.xml"
73-
},
74-
"husky": {
75-
"hooks": {
76-
"pre-commit": "npm run lint && npm run test -- -b"
77-
}
7864
}
7965
}

src/decorator/handler/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ type Handler = (_target: unknown, _propertyName: string, propertyDescriptor: Pro
44

55
export function APIGatewayProxyHandler(args?: handlers.APIGatewayProxyHandlerArguments): Handler {
66
const handler = new handlers.APIGatewayProxyHandler(args);
7-
return (handler.decorator.bind(handler) as unknown) as Handler;
7+
return handler.decorator.bind(handler) as unknown as Handler;
88
}

src/format/InputFormat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ export class InputFormat {
1313
}
1414
}
1515

16-
export const json: Format = (InputFormat.json as unknown) as Format;
16+
export const json: Format = InputFormat.json as unknown as Format;

src/format/OutputFormat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export class OutputFormat {
88
}
99
}
1010

11-
export const json: Format = (OutputFormat.json as unknown) as Format;
11+
export const json: Format = OutputFormat.json as unknown as Format;

src/handler/APIGatewayProxyHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class APIGatewayProxyHandler extends BaseHandler {
9696
protected formatOutput(result: APIGatewayResponse): APIGatewayProxyResult {
9797
const { body, ...properties } = result;
9898
return {
99-
...(body && { body: this.outputFormat.apply(body) }),
99+
body: body ? this.outputFormat.apply(body) : "",
100100
...properties,
101101
};
102102
}

src/handler/BaseHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export abstract class BaseHandler {
115115
const instance = this;
116116
return handler.after(await method.apply(instance, handler.before(event, context)));
117117
} catch (err) {
118-
return handler.onException(err);
118+
return handler.onException(err as Error);
119119
}
120120
};
121121
}

0 commit comments

Comments
 (0)