@easel-sh/cli 0.1.0-alpha.7 → 0.1.0-alpha.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"handler-wrapper.d.ts","sourceRoot":"","sources":["../src/handler-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAkRlE"}
1
+ {"version":3,"file":"handler-wrapper.d.ts","sourceRoot":"","sources":["../src/handler-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAwRlE"}
@@ -21,6 +21,13 @@ function getModule() {
21
21
  return userModulePromise;
22
22
  }
23
23
 
24
+ function normalizeStatus(status) {
25
+ // Valid HTTP status is 100-599. Response.status can be 0 for error/opaque (Fetch API).
26
+ if (typeof status === "number" && status >= 100 && status < 600) return status;
27
+ if (status === 0) return 502; // error/opaque response
28
+ return 200;
29
+ }
30
+
24
31
  async function responseToLambda(response) {
25
32
  const responseHeaders = {};
26
33
  response.headers.forEach((value, key) => {
@@ -28,7 +35,7 @@ async function responseToLambda(response) {
28
35
  });
29
36
  const body = await response.text();
30
37
  return {
31
- statusCode: response.status || 200,
38
+ statusCode: normalizeStatus(response.status),
32
39
  headers: responseHeaders,
33
40
  body: body,
34
41
  };
@@ -49,14 +56,12 @@ module.exports.handler = async (event, _context) => {
49
56
  }
50
57
 
51
58
  const queryParams = { ...(event.queryStringParameters || {}) };
52
- let path = "/";
53
- const matchedPath = normalizedHeaders["x-matched-path"];
54
- if (matchedPath) {
55
- path = matchedPath.startsWith("/") ? matchedPath : "/" + matchedPath;
56
- } else {
57
- path = isV2 ? event.rawPath || event.path || "/" : event.path || "/";
58
- }
59
-
59
+ // Prefer original client path from router when present so Lambda sees the same URL the client requested (event.rawPath may be wrong if event was built by API Gateway or an older gateway)
60
+ const originalPath = normalizedHeaders["x-router-original-path"];
61
+ const pathFromEvent = isV2 ? event.rawPath || event.path || "/" : event.path || "/";
62
+ const path = (originalPath && originalPath.trim())
63
+ ? (originalPath.trim().startsWith("/") ? originalPath.trim() : "/" + originalPath.trim())
64
+ : pathFromEvent;
60
65
  const host = event.headers?.host || event.headers?.["host"] || "localhost";
61
66
  const url = new URL(path, "http://" + host);
62
67
  Object.entries(queryParams).forEach(([key, value]) => {
@@ -180,10 +185,11 @@ module.exports.handler = async (event, _context) => {
180
185
  const headers = {};
181
186
  let body = "";
182
187
  let headersSent = false;
188
+ let resolved = false;
183
189
 
184
190
  function finishRes() {
185
- if (headersSent) return;
186
- headersSent = true;
191
+ if (resolved) return;
192
+ resolved = true;
187
193
  const out = {};
188
194
  Object.entries(headers).forEach(([k, v]) => {
189
195
  out[k] = Array.isArray(v) ? v.join(", ") : v;
@@ -1 +1 @@
1
- {"version":3,"file":"handler-wrapper.js","sourceRoot":"","sources":["../src/handler-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3E,OAAO;;;;;;;;;;iCAUwB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqQ3C,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"handler-wrapper.js","sourceRoot":"","sources":["../src/handler-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3E,OAAO;;;;;;;;;;iCAUwB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Q3C,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easel-sh/cli",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "cli": "./dist/cli.js"