@middy/http-partial-response 3.0.0-alpha.5 → 3.0.0-alpha.8

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.
Files changed (4) hide show
  1. package/README.md +24 -16
  2. package/index.cjs +3 -0
  3. package/index.js +2 -33
  4. package/package.json +13 -6
package/README.md CHANGED
@@ -1,26 +1,36 @@
1
- # Middy http-partial-response middleware
2
-
3
- <div align="center">
4
- <img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/docs/img/middy-logo.png"/>
5
- </div>
6
-
7
1
  <div align="center">
2
+ <h1>Middy http-partial-response middleware</h1>
3
+ <img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/docs/img/middy-logo.svg"/>
8
4
  <p><strong>HTTP partial response middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
9
- </div>
10
-
11
- <div align="center">
12
5
  <p>
13
- <a href="http://badge.fury.io/js/%40middy%2Fhttp-partial-response">
6
+ <a href="https://www.npmjs.com/package/@middy/http-partial-response?activeTab=versions">
14
7
  <img src="https://badge.fury.io/js/%40middy%2Fhttp-partial-response.svg" alt="npm version" style="max-width:100%;">
15
8
  </a>
9
+ <a href="https://packagephobia.com/result?p=@middy/http-partial-response">
10
+ <img src="https://packagephobia.com/badge?p=@middy/http-partial-response" alt="npm install size" style="max-width:100%;">
11
+ </a>
12
+ <a href="https://github.com/middyjs/middy/actions">
13
+ <img src="https://github.com/middyjs/middy/workflows/Tests/badge.svg" alt="GitHub Actions test status badge" style="max-width:100%;">
14
+ </a>
15
+ <br/>
16
+ <a href="https://standardjs.com/">
17
+ <img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard Code Style" style="max-width:100%;">
18
+ </a>
16
19
  <a href="https://snyk.io/test/github/middyjs/middy">
17
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%;">
18
21
  </a>
19
- <a href="https://standardjs.com/">
20
- <img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard Code Style" style="max-width:100%;">
22
+ <a href="https://lgtm.com/projects/g/middyjs/middy/context:javascript">
23
+ <img src="https://img.shields.io/lgtm/grade/javascript/g/middyjs/middy.svg?logo=lgtm&logoWidth=18" alt="Language grade: JavaScript" style="max-width:100%;">
21
24
  </a>
25
+ <a href="https://bestpractices.coreinfrastructure.org/projects/5280">
26
+ <img src="https://bestpractices.coreinfrastructure.org/projects/5280/badge" alt="Core Infrastructure Initiative (CII) Best Practices" style="max-width:100%;">
27
+ </a>
28
+ <br/>
22
29
  <a href="https://gitter.im/middyjs/Lobby">
23
- <img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
30
+ <img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
31
+ </a>
32
+ <a href="https://stackoverflow.com/questions/tagged/middy?sort=Newest&uqlId=35052">
33
+ <img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;">
24
34
  </a>
25
35
  </p>
26
36
  </div>
@@ -40,9 +50,7 @@ npm install --save @middy/http-partial-response
40
50
 
41
51
 
42
52
  ## Options
43
-
44
- This middleware does not have any option
45
-
53
+ None
46
54
 
47
55
  ## Sample usage
48
56
 
package/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _jsonMask=_interopRequireDefault(require("json-mask"));var _util=require("@middy/util");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}const defaults={filteringKeyName:"fields"};const httpPartialResponseMiddleware=(opts={})=>{const options={...defaults,...opts};const{filteringKeyName}=options;const httpPartialResponseMiddlewareAfter=async request=>{const fields=request.event?.queryStringParameters?.[filteringKeyName];if(!fields)return;(0,_util).normalizeHttpResponse(request);const body=request.response.body;const bodyIsString=typeof body==="string";const parsedBody=(0,_util).jsonSafeParse(body);if(typeof parsedBody!=="object")return;const filteredBody=(0,_jsonMask).default(parsedBody,fields);request.response.body=bodyIsString?JSON.stringify(filteredBody):filteredBody};return{after:httpPartialResponseMiddlewareAfter}};var _default=httpPartialResponseMiddleware;exports.default=_default
2
+
3
+ //# sourceMappingURL=index.cjs.map
package/index.js CHANGED
@@ -1,34 +1,3 @@
1
- import mask from 'json-mask';
2
- import { normalizeHttpResponse, jsonSafeParse } from '@middy/util';
3
- const defaults = {
4
- filteringKeyName: 'fields'
5
- };
1
+ import mask from"json-mask";import{normalizeHttpResponse,jsonSafeParse}from"@middy/util";const defaults={filteringKeyName:"fields"};const httpPartialResponseMiddleware=(opts={})=>{const options={...defaults,...opts};const{filteringKeyName}=options;const httpPartialResponseMiddlewareAfter=async request=>{const fields=request.event?.queryStringParameters?.[filteringKeyName];if(!fields)return;normalizeHttpResponse(request);const body=request.response.body;const bodyIsString=typeof body==="string";const parsedBody=jsonSafeParse(body);if(typeof parsedBody!=="object")return;const filteredBody=mask(parsedBody,fields);request.response.body=bodyIsString?JSON.stringify(filteredBody):filteredBody};return{after:httpPartialResponseMiddlewareAfter}};export default httpPartialResponseMiddleware
6
2
 
7
- const httpPartialResponseMiddleware = (opts = {}) => {
8
- const options = { ...defaults,
9
- ...opts
10
- };
11
- const {
12
- filteringKeyName
13
- } = options;
14
-
15
- const httpPartialResponseMiddlewareAfter = async request => {
16
- var _request$event, _request$event$queryS;
17
-
18
- const fields = (_request$event = request.event) === null || _request$event === void 0 ? void 0 : (_request$event$queryS = _request$event.queryStringParameters) === null || _request$event$queryS === void 0 ? void 0 : _request$event$queryS[filteringKeyName];
19
- if (!fields) return;
20
- normalizeHttpResponse(request);
21
- const body = request.response.body;
22
- const bodyIsString = typeof body === 'string';
23
- const parsedBody = jsonSafeParse(body);
24
- if (typeof parsedBody !== 'object') return;
25
- const filteredBody = mask(parsedBody, fields);
26
- request.response.body = bodyIsString ? JSON.stringify(filteredBody) : filteredBody;
27
- };
28
-
29
- return {
30
- after: httpPartialResponseMiddlewareAfter
31
- };
32
- };
33
-
34
- export default httpPartialResponseMiddleware;
3
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-partial-response",
3
- "version": "3.0.0-alpha.5",
3
+ "version": "3.0.0-alpha.8",
4
4
  "description": "Http partial response middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -10,10 +10,17 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "exports": "./index.js",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./index.js",
16
+ "require": "./index.cjs",
17
+ "types": "./index.d.ts"
18
+ }
19
+ },
14
20
  "types": "index.d.ts",
15
21
  "files": [
16
22
  "index.js",
23
+ "index.cjs",
17
24
  "index.d.ts"
18
25
  ],
19
26
  "scripts": {
@@ -47,13 +54,13 @@
47
54
  "bugs": {
48
55
  "url": "https://github.com/middyjs/middy/issues"
49
56
  },
50
- "homepage": "https://github.com/middyjs/middy#readme",
57
+ "homepage": "https://middy.js.org",
51
58
  "dependencies": {
52
- "@middy/util": "^3.0.0-alpha.5",
59
+ "@middy/util": "^3.0.0-alpha.8",
53
60
  "json-mask": "1.0.4"
54
61
  },
55
- "gitHead": "cf6a1b02a2e163bea353b10146d67e0d95ef8072",
62
+ "gitHead": "c04b3a0c2f326906b34973878d6f823778a5ea99",
56
63
  "devDependencies": {
57
- "@middy/core": "^3.0.0-alpha.5"
64
+ "@middy/core": "^3.0.0-alpha.8"
58
65
  }
59
66
  }