@middy/http-multipart-body-parser
Advanced tools
Comparing version 4.0.10 to 4.1.0
@@ -23,2 +23,3 @@ import middy from '@middy/core' | ||
charset?: string | ||
disableContentTypeError?: boolean | ||
} | ||
@@ -25,0 +26,0 @@ |
14
index.js
@@ -7,3 +7,4 @@ import BusBoy from 'busboy'; | ||
busboy: {}, | ||
charset: 'utf8' | ||
charset: 'utf8', | ||
disableContentTypeError: true | ||
}; | ||
@@ -18,7 +19,14 @@ const httpMultipartBodyParserMiddleware = (opts = {})=>{ | ||
const contentType = headers['Content-Type'] ?? headers['content-type']; | ||
if (!mimePattern.test(contentType)) return; | ||
if (!mimePattern.test(contentType)) { | ||
if (options.disableContentTypeError) { | ||
return; | ||
} | ||
throw createError(415, '@middy/http-multipart-body-parser Unsupported Media Type', { | ||
cause: contentType | ||
}); | ||
} | ||
return parseMultipartData(request.event, options).then((multipartData)=>{ | ||
request.event.body = multipartData; | ||
}).catch((cause)=>{ | ||
throw createError(422, 'Invalid or malformed multipart/form-data was provided', { | ||
throw createError(415, 'Invalid or malformed multipart/form-data was provided', { | ||
cause | ||
@@ -25,0 +33,0 @@ }); |
{ | ||
"name": "@middy/http-multipart-body-parser", | ||
"version": "4.0.10", | ||
"version": "4.1.0", | ||
"description": "Http event normalizer middleware for the middy framework", | ||
@@ -65,11 +65,11 @@ "type": "module", | ||
"dependencies": { | ||
"@middy/util": "4.0.10", | ||
"@middy/util": "4.1.0", | ||
"busboy": "1.6.0" | ||
}, | ||
"devDependencies": { | ||
"@middy/core": "4.0.10", | ||
"@middy/core": "4.1.0", | ||
"@types/aws-lambda": "^8.10.101", | ||
"type-fest": "^3.0.0" | ||
}, | ||
"gitHead": "e2a97d380fc4150781004092ea054f5d0fc7a8c0" | ||
"gitHead": "c5abbac9280c3a2f30758188233a7b27367901d1" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13180
215
+ Added@middy/util@4.1.0(transitive)
- Removed@middy/util@4.0.10(transitive)
Updated@middy/util@4.1.0