@easel-sh/cli 0.1.0-alpha.8 → 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,
|
|
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"}
|
package/dist/handler-wrapper.js
CHANGED
|
@@ -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
|
|
38
|
+
statusCode: normalizeStatus(response.status),
|
|
32
39
|
headers: responseHeaders,
|
|
33
40
|
body: body,
|
|
34
41
|
};
|
|
@@ -178,10 +185,11 @@ module.exports.handler = async (event, _context) => {
|
|
|
178
185
|
const headers = {};
|
|
179
186
|
let body = "";
|
|
180
187
|
let headersSent = false;
|
|
188
|
+
let resolved = false;
|
|
181
189
|
|
|
182
190
|
function finishRes() {
|
|
183
|
-
if (
|
|
184
|
-
|
|
191
|
+
if (resolved) return;
|
|
192
|
+
resolved = true;
|
|
185
193
|
const out = {};
|
|
186
194
|
Object.entries(headers).forEach(([k, v]) => {
|
|
187
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
|
|
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"}
|