effortless-aws 0.2.0 → 0.2.1
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.
|
@@ -15,11 +15,15 @@ var parseBody = (body, isBase64) => {
|
|
|
15
15
|
};
|
|
16
16
|
var wrapHttp = (handler) => {
|
|
17
17
|
const rt = createHandlerRuntime(handler, "http");
|
|
18
|
-
const toResult = (r) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const toResult = (r) => {
|
|
19
|
+
const customContentType = r.headers?.["content-type"] ?? r.headers?.["Content-Type"];
|
|
20
|
+
const isJson = !customContentType || customContentType.includes("application/json");
|
|
21
|
+
return {
|
|
22
|
+
statusCode: r.status,
|
|
23
|
+
headers: { ...isJson ? { "Content-Type": "application/json" } : {}, ...r.headers },
|
|
24
|
+
body: isJson ? JSON.stringify(r.body) : String(r.body ?? "")
|
|
25
|
+
};
|
|
26
|
+
};
|
|
23
27
|
const defaultError = (error, status) => {
|
|
24
28
|
console.error(`[effortless:${rt.handlerName}]`, error);
|
|
25
29
|
return {
|