Skip to content

Commit 5dd19fb

Browse files
committed
refactor: debug logs
Signed-off-by: seven <[email protected]>
1 parent b59950a commit 5dd19fb

File tree

5 files changed

+69
-40
lines changed

5 files changed

+69
-40
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "dist/src/index.js",
77
"types": "dist/src/index.d.ts",
88
"scripts": {
9-
"test": "DEBUG=serverless-adapter jest --runInBand --detectOpenHandles --coverage --coverageReporters json-summary text html lcov",
9+
"test": "jest --runInBand --detectOpenHandles --coverage --coverageReporters json-summary text html lcov",
1010
"test:ci": "jest --runInBand --ci --coverage --coverageReporters json-summary text html lcov",
1111
"build": "tsc --build",
1212
"lint:fix": "eslint --fix ./",
@@ -46,22 +46,22 @@
4646
"function"
4747
],
4848
"dependencies": {
49-
"pino": "^9.4.0",
50-
"pino-pretty": "^11.2.2",
49+
"debug": "^4.3.7",
5150
"raw-body": "^3.0.0"
5251
},
5352
"devDependencies": {
5453
"@eslint/js": "^9.12.0",
54+
"@types/debug": "^4.1.12",
5555
"@types/express": "^5.0.0",
5656
"@types/jest": "^29.5.13",
5757
"@types/node": "^22.7.4",
5858
"@typescript-eslint/eslint-plugin": "^8.8.0",
5959
"@typescript-eslint/parser": "^8.8.0",
60+
"body-parser": "^1.20.3",
6061
"eslint": "^8.57.1",
6162
"eslint-config-prettier": "^9.1.0",
6263
"eslint-plugin-prettier": "^5.2.1",
6364
"express": "^4.21.0",
64-
"body-parser": "^1.20.3",
6565
"globals": "^15.10.0",
6666
"husky": "^9.1.6",
6767
"jest": "^29.7.0",

src/common/debug.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import getDebug from 'debug';
2+
3+
const debug = getDebug('serverless-adapter');
4+
5+
export { debug };

src/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './debug';

src/context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { Context, Event } from './types';
22
import ServerlessRequest from './serverlessRequest';
33
import url from 'node:url';
44
import ServerlessResponse from './serverlessResponse';
5+
import { debug } from './common';
56

67
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7-
export const constructFrameworkContext = (event: Event, _: Context) => {
8+
export const constructFrameworkContext = (event: Event, context: Context) => {
9+
debug(`constructFrameworkContext: ${JSON.stringify({ event, context })}`);
810
const request = new ServerlessRequest({
911
method: event.httpMethod,
1012
headers: event.headers,

0 commit comments

Comments
 (0)