@middy/core 5.5.1 → 6.0.0-beta.0

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 (2) hide show
  1. package/index.js +6 -3
  2. package/package.json +7 -6
package/index.js CHANGED
@@ -63,7 +63,6 @@ const middy = (lambdaHandler = defaultLambdaHandler, plugin = {}) => {
63
63
  )
64
64
  }
65
65
 
66
- // Source @datastream/core (MIT)
67
66
  let handlerStream
68
67
  if (handlerBody._readableState) {
69
68
  handlerStream = handlerBody
@@ -154,7 +153,7 @@ const runRequest = async (
154
153
  await runMiddlewares(request, beforeMiddlewares, plugin)
155
154
 
156
155
  // Check if before stack hasn't exit early
157
- if (typeof request.response === 'undefined') {
156
+ if (!Object.prototype.hasOwnProperty.call(request, 'earlyResponse')) {
158
157
  plugin.beforeHandler?.()
159
158
 
160
159
  // Can't manually abort and timeout with same AbortSignal
@@ -231,7 +230,11 @@ const runMiddlewares = async (request, middlewares, plugin) => {
231
230
  plugin.afterMiddleware?.(nextMiddleware.name)
232
231
  // short circuit chaining and respond early
233
232
  if (typeof res !== 'undefined') {
234
- request.response = res
233
+ request.earlyResponse = res
234
+ }
235
+ // earlyResponse pattern added in 6.0.0 to handle undefined values
236
+ if (Object.prototype.hasOwnProperty.call(request, 'earlyResponse')) {
237
+ request.response = request.earlyResponse
235
238
  return
236
239
  }
237
240
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@middy/core",
3
- "version": "5.5.1",
3
+ "version": "6.0.0-beta.0",
4
4
  "description": "🛵 The stylish Node.js middleware engine for AWS Lambda (core package)",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">=18"
7
+ "node": ">=20"
8
8
  },
9
9
  "engineStrict": true,
10
10
  "publishConfig": {
@@ -16,6 +16,9 @@
16
16
  "import": {
17
17
  "types": "./index.d.ts",
18
18
  "default": "./index.js"
19
+ },
20
+ "require": {
21
+ "default": "./index.js"
19
22
  }
20
23
  }
21
24
  },
@@ -57,11 +60,9 @@
57
60
  "url": "https://github.com/sponsors/willfarrell"
58
61
  },
59
62
  "devDependencies": {
63
+ "@datastream/core": "0.0.40",
60
64
  "@types/aws-lambda": "^8.10.76",
61
65
  "@types/node": "^20.0.0"
62
66
  },
63
- "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431",
64
- "dependencies": {
65
- "@datastream/core": "0.0.38"
66
- }
67
+ "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
67
68
  }