@middy/http-partial-response 5.0.0-alpha.0 → 5.0.0-alpha.2
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 +3 -2
- package/index.js +1 -1
- package/package.json +4 -10
- package/index.cjs +0 -41
package/README.md
CHANGED
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
<a href="https://snyk.io/test/github/middyjs/middy">
|
|
20
20
|
<img src="https://snyk.io/test/github/middyjs/middy/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/middyjs/middy" style="max-width:100%;">
|
|
21
21
|
</a>
|
|
22
|
-
<a href="https://
|
|
23
|
-
<img src="https://
|
|
22
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/sast.yml">
|
|
23
|
+
<img src="https://github.com/middyjs/middy/actions/workflows/sast.yml/badge.svg
|
|
24
|
+
?branch=main&event=push" alt="CodeQL" style="max-width:100%;">
|
|
24
25
|
</a>
|
|
25
26
|
<a href="https://bestpractices.coreinfrastructure.org/projects/5280">
|
|
26
27
|
<img src="https://bestpractices.coreinfrastructure.org/projects/5280/badge" alt="Core Infrastructure Initiative (CII) Best Practices" style="max-width:100%;">
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const httpPartialResponseMiddleware = (opts = {})=>{
|
|
|
8
8
|
...defaults,
|
|
9
9
|
...opts
|
|
10
10
|
};
|
|
11
|
-
const { filteringKeyName
|
|
11
|
+
const { filteringKeyName } = options;
|
|
12
12
|
const httpPartialResponseMiddlewareAfter = async (request)=>{
|
|
13
13
|
const fields = request.event?.queryStringParameters?.[filteringKeyName];
|
|
14
14
|
if (!fields) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-partial-response",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.2",
|
|
4
4
|
"description": "Http partial response middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -10,24 +10,18 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"main": "./index.cjs",
|
|
14
13
|
"module": "./index.js",
|
|
15
14
|
"exports": {
|
|
16
15
|
".": {
|
|
17
16
|
"import": {
|
|
18
17
|
"types": "./index.d.ts",
|
|
19
18
|
"default": "./index.js"
|
|
20
|
-
},
|
|
21
|
-
"require": {
|
|
22
|
-
"types": "./index.d.ts",
|
|
23
|
-
"default": "./index.cjs"
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
21
|
},
|
|
27
22
|
"types": "index.d.ts",
|
|
28
23
|
"files": [
|
|
29
24
|
"index.js",
|
|
30
|
-
"index.cjs",
|
|
31
25
|
"index.d.ts"
|
|
32
26
|
],
|
|
33
27
|
"scripts": {
|
|
@@ -67,11 +61,11 @@
|
|
|
67
61
|
"url": "https://github.com/sponsors/willfarrell"
|
|
68
62
|
},
|
|
69
63
|
"dependencies": {
|
|
70
|
-
"@middy/util": "5.0.0-alpha.
|
|
64
|
+
"@middy/util": "5.0.0-alpha.2",
|
|
71
65
|
"json-mask": "2.0.0"
|
|
72
66
|
},
|
|
73
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "ebce8d5df8783077fa49ba62ee9be20e8486a7f1",
|
|
74
68
|
"devDependencies": {
|
|
75
|
-
"@middy/core": "5.0.0-alpha.
|
|
69
|
+
"@middy/core": "5.0.0-alpha.2"
|
|
76
70
|
}
|
|
77
71
|
}
|
package/index.cjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(module, "exports", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>_default
|
|
8
|
-
});
|
|
9
|
-
const _jsonMask = _interopRequireDefault(require("json-mask"));
|
|
10
|
-
const _util = require("@middy/util");
|
|
11
|
-
function _interopRequireDefault(obj) {
|
|
12
|
-
return obj && obj.__esModule ? obj : {
|
|
13
|
-
default: obj
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const defaults = {
|
|
17
|
-
filteringKeyName: 'fields'
|
|
18
|
-
};
|
|
19
|
-
const httpPartialResponseMiddleware = (opts = {})=>{
|
|
20
|
-
const options = {
|
|
21
|
-
...defaults,
|
|
22
|
-
...opts
|
|
23
|
-
};
|
|
24
|
-
const { filteringKeyName } = options;
|
|
25
|
-
const httpPartialResponseMiddlewareAfter = async (request)=>{
|
|
26
|
-
const fields = request.event?.queryStringParameters?.[filteringKeyName];
|
|
27
|
-
if (!fields) return;
|
|
28
|
-
(0, _util.normalizeHttpResponse)(request);
|
|
29
|
-
const body = request.response.body;
|
|
30
|
-
const bodyIsString = typeof body === 'string';
|
|
31
|
-
const parsedBody = (0, _util.jsonSafeParse)(body);
|
|
32
|
-
if (typeof parsedBody !== 'object') return;
|
|
33
|
-
const filteredBody = (0, _jsonMask.default)(parsedBody, fields);
|
|
34
|
-
request.response.body = bodyIsString ? JSON.stringify(filteredBody) : filteredBody;
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
after: httpPartialResponseMiddlewareAfter
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const _default = httpPartialResponseMiddleware;
|
|
41
|
-
|