3.0.0
Checkout UPGRADE.md
to see what are the main breaking changes and how to migrate to this new version if coming from 2.x
.
Version 3.x of Middy no longer supports Node.js versions 12.x. You are highly encouraged to move to Node.js 16.x.
With the Node.js version change all packages are now ECMAScript Modules along side CommonJS Modules.
Notable changes
- New WebSocket middlewares
- HTTP & WebSocket Routers!
- Better error handling
- Timeout error handling
- Errors now use
{ cause }
for better context
Additions
- New middleware (
http-content-encoding
,http-router
,service-discovery
,ws-json-body-parser
,ws-response
,ws-router
) core
- Added
.handler()
method to allow easier understanding of the execution cycle - lambdaHandler can now be passed an
AbortController
signal - internal events can now be monitored using
Proxy
- Added
util
getInternal
error now includescause
set to an array of Errors- Catch when
X-Ray
is applied outside of handler invocation scope
Breaking Changes
core
- The order
onError
being called is now reversed to matchafter
- If you only use
@middy/*
middlewares no change should be required - If you have custom error handling middleware or other custom middleware that
return response
, additional testing is high recommended
- If you only use
- Deprecate
applyMiddleware()
and__middlewares
- The order
util
normalizeHttpResponse
now takesrequest
and mutates responsegetCache
will return{}
instead ofundefined
when not found
- Deprecated
setToEnv
option from all middleware - Will now throw error if not an http event in
http-event-normalizer
- Change default charset from
binary
/latin1
toutf-8
withinhttp-multipart-body-parser
- Renamed
default
option todefaultContentType
to improve maintainability inhttp-response-serializer
- Deprecate
expectCt
inhttp-security-headers
sqs-partial-batch-failure
completely rewritten- Renamed
default
option todefaultContentType
http-response-serializer
normalizeHttpResponse
now takesrequest
and mutates response- Change where errors are stored, from
request.error.details
torequest.error.cause
invalidator
Removed
s3-key-normalizer
in favour ofevent-normalizer
sqs-json-body-parser
in favour ofevent-normalizer
Maintenance
- Better error reporting when dealing with Promise arrays
Full Changelog: 2.5.7...3.0.0