@middy/input-output-logger 7.1.2 → 7.1.4
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.
- package/README.md +18 -5
- package/index.d.ts +4 -2
- package/index.js +14 -14
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -30,10 +30,23 @@
|
|
|
30
30
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/input-output-logger">https://middy.js.org/docs/middlewares/input-output-logger</a></p>
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install --save @middy/input-output-logger
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Documentation and examples
|
|
41
|
+
|
|
42
|
+
For documentation and examples, refer to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org/docs/middlewares/input-output-logger).
|
|
34
43
|
|
|
35
|
-
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
|
package/index.d.ts
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
import type middy from "@middy/core";
|
|
4
4
|
|
|
5
5
|
export interface Options {
|
|
6
|
-
logger?: (message:
|
|
6
|
+
logger?: (message: unknown) => void;
|
|
7
7
|
executionContext?: boolean;
|
|
8
8
|
lambdaContext?: boolean;
|
|
9
9
|
omitPaths?: string[];
|
|
10
10
|
mask?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
declare function inputOutputLogger(
|
|
13
|
+
declare function inputOutputLogger(
|
|
14
|
+
options?: Options,
|
|
15
|
+
): middy.MiddlewareObj<unknown, unknown, Error>;
|
|
14
16
|
|
|
15
17
|
export default inputOutputLogger;
|
package/index.js
CHANGED
|
@@ -63,7 +63,9 @@ const inputOutputLoggerMiddleware = (opts = {}) => {
|
|
|
63
63
|
|
|
64
64
|
let cloneMessage = message;
|
|
65
65
|
if (omitPaths.length) {
|
|
66
|
-
|
|
66
|
+
// Clone only the branch being omitted, not the entire message
|
|
67
|
+
cloneMessage = { ...message };
|
|
68
|
+
cloneMessage[param] = structuredClone(message[param]);
|
|
67
69
|
omit(cloneMessage, { [param]: omitPathTree[param] });
|
|
68
70
|
}
|
|
69
71
|
logger(cloneMessage);
|
|
@@ -90,10 +92,10 @@ const inputOutputLoggerMiddleware = (opts = {}) => {
|
|
|
90
92
|
}
|
|
91
93
|
};
|
|
92
94
|
|
|
93
|
-
const inputOutputLoggerMiddlewareBefore =
|
|
95
|
+
const inputOutputLoggerMiddlewareBefore = (request) => {
|
|
94
96
|
omitAndLog("event", request);
|
|
95
97
|
};
|
|
96
|
-
const inputOutputLoggerMiddlewareAfter =
|
|
98
|
+
const inputOutputLoggerMiddlewareAfter = (request) => {
|
|
97
99
|
// Check for Node.js stream
|
|
98
100
|
if (
|
|
99
101
|
request.response?._readableState ??
|
|
@@ -112,7 +114,7 @@ const inputOutputLoggerMiddleware = (opts = {}) => {
|
|
|
112
114
|
}
|
|
113
115
|
};
|
|
114
116
|
const inputOutputLoggerMiddlewareOnError = async (request) => {
|
|
115
|
-
if (request.response === undefined) return;
|
|
117
|
+
if (typeof request.response === "undefined") return;
|
|
116
118
|
await inputOutputLoggerMiddlewareAfter(request);
|
|
117
119
|
};
|
|
118
120
|
|
|
@@ -144,16 +146,14 @@ const buildPathTree = (paths) => {
|
|
|
144
146
|
// reverse to ensure conflicting paths don't cause issues
|
|
145
147
|
if (!Array.isArray(path)) path = path.split(".");
|
|
146
148
|
if (path.includes("__proto__")) continue;
|
|
147
|
-
path
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return true;
|
|
156
|
-
}, tree);
|
|
149
|
+
path.reduce((a, b, idx) => {
|
|
150
|
+
if (idx < path.length - 1) {
|
|
151
|
+
a[b] ??= {};
|
|
152
|
+
return a[b];
|
|
153
|
+
}
|
|
154
|
+
a[b] = true;
|
|
155
|
+
return true;
|
|
156
|
+
}, tree);
|
|
157
157
|
}
|
|
158
158
|
return tree;
|
|
159
159
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/input-output-logger",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.4",
|
|
4
4
|
"description": "Input and output logger middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -65,13 +65,12 @@
|
|
|
65
65
|
"url": "https://github.com/sponsors/willfarrell"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@middy/util": "7.1.
|
|
68
|
+
"@middy/util": "7.1.4"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@datastream/core": "0.0.42",
|
|
72
|
-
"@middy/core": "7.1.
|
|
72
|
+
"@middy/core": "7.1.4",
|
|
73
73
|
"@types/aws-lambda": "^8.0.0",
|
|
74
74
|
"@types/node": "^22.0.0"
|
|
75
|
-
}
|
|
76
|
-
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
|
|
75
|
+
}
|
|
77
76
|
}
|