@middy/http-multipart-body-parser 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 CHANGED
@@ -30,10 +30,23 @@
30
30
  <p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/http-multipart-body-parser">https://middy.js.org/docs/middlewares/http-multipart-body-parser</a></p>
31
31
  </div>
32
32
 
33
- ## License
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install --save @middy/http-multipart-body-parser
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/http-multipart-body-parser).
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
- <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
38
- <img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
39
- </a>
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
@@ -6,7 +6,7 @@ import type { JsonValue } from "type-fest";
6
6
 
7
7
  export interface Options {
8
8
  busboy?: {
9
- headers?: any;
9
+ headers?: Record<string, string>;
10
10
  highWaterMark?: number;
11
11
  fileHwm?: number;
12
12
  defCharset?: string;
@@ -22,6 +22,7 @@ export interface Options {
22
22
  };
23
23
  };
24
24
  charset?: string;
25
+ disableContentTypeCheck?: boolean;
25
26
  disableContentTypeError?: boolean;
26
27
  }
27
28
 
@@ -31,6 +32,6 @@ export type Event = Omit<APIGatewayEvent, "body"> & {
31
32
 
32
33
  declare function multipartBodyParser(
33
34
  options?: Options,
34
- ): middy.MiddlewareObj<Event>;
35
+ ): middy.MiddlewareObj<Event, unknown, Error>;
35
36
 
36
37
  export default multipartBodyParser;
package/index.js CHANGED
@@ -4,7 +4,7 @@ import BusBoy from "@fastify/busboy";
4
4
  import { createError } from "@middy/util";
5
5
 
6
6
  const mimePattern =
7
- /^multipart\/form-data; boundary=[a-zA-Z0-9-]{1,70}(; ?[cC]harset=[\w-]+)?$/;
7
+ /^multipart\/form-data; boundary=[a-zA-Z0-9-]{1,70}(; ?charset=[\w-]+)?$/i;
8
8
  const fieldnamePattern = /(.+)\[(.*)]$/;
9
9
 
10
10
  const defaults = {
@@ -18,7 +18,7 @@ const defaults = {
18
18
  const httpMultipartBodyParserMiddleware = (opts = {}) => {
19
19
  const options = { ...defaults, ...opts };
20
20
 
21
- const httpMultipartBodyParserMiddlewareBefore = async (request) => {
21
+ const httpMultipartBodyParserMiddlewareBefore = (request) => {
22
22
  const { headers, body } = request.event;
23
23
 
24
24
  const contentType = headers?.["content-type"] ?? headers?.["Content-Type"];
@@ -37,7 +37,7 @@ const httpMultipartBodyParserMiddleware = (opts = {}) => {
37
37
 
38
38
  if (typeof body === "undefined") {
39
39
  throw createError(
40
- 415,
40
+ 422,
41
41
  "Invalid or malformed multipart/form-data was provided",
42
42
  { cause: { package: "@middy/http-multipart-body-parser", data: body } },
43
43
  );
@@ -45,13 +45,12 @@ const httpMultipartBodyParserMiddleware = (opts = {}) => {
45
45
 
46
46
  return parseMultipartData(request.event, options)
47
47
  .then((multipartData) => {
48
- // request.event.rawBody = body
49
48
  request.event.body = multipartData;
50
49
  })
51
50
  .catch((err) => {
52
51
  // UnprocessableEntity
53
52
  throw createError(
54
- 415,
53
+ 422,
55
54
  "Invalid or malformed multipart/form-data was provided",
56
55
  {
57
56
  cause: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-multipart-body-parser",
3
- "version": "7.1.2",
3
+ "version": "7.1.4",
4
4
  "description": "HTTP multipart body parser middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -66,12 +66,12 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@fastify/busboy": "3.2.0",
69
- "@middy/util": "7.1.2"
69
+ "@middy/util": "7.1.4"
70
70
  },
71
71
  "devDependencies": {
72
- "@middy/core": "7.1.2",
72
+ "@middy/core": "7.1.4",
73
73
  "@types/aws-lambda": "^8.0.0",
74
+ "@types/node": "^22.0.0",
74
75
  "type-fest": "^5.0.0"
75
- },
76
- "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
76
+ }
77
77
  }