silgi 0.35.3 → 0.35.5
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.
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.mjs +1 -37
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -390,38 +390,6 @@ async function parseRequestInput(req) {
|
|
|
390
390
|
}
|
|
391
391
|
return await req.text();
|
|
392
392
|
}
|
|
393
|
-
function wrapBodyAndContentType(options) {
|
|
394
|
-
let { body, headers } = options;
|
|
395
|
-
const setContentType = (type) => {
|
|
396
|
-
if (!headers)
|
|
397
|
-
headers = {};
|
|
398
|
-
if (headers instanceof Headers) {
|
|
399
|
-
if (!headers.has("Content-Type"))
|
|
400
|
-
headers.set("Content-Type", type);
|
|
401
|
-
} else if (Array.isArray(headers)) {
|
|
402
|
-
if (!headers.some(([k]) => k.toLowerCase() === "content-type")) {
|
|
403
|
-
headers.push(["Content-Type", type]);
|
|
404
|
-
}
|
|
405
|
-
} else {
|
|
406
|
-
if (!("content-type" in headers)) {
|
|
407
|
-
headers["Content-Type"] = type;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
if (typeof File !== "undefined" && body instanceof File) {
|
|
412
|
-
body = new Blob([body], { type: body.type });
|
|
413
|
-
setContentType(body.type || "application/octet-stream");
|
|
414
|
-
} else if (body instanceof Blob) {
|
|
415
|
-
setContentType(body.type || "application/octet-stream");
|
|
416
|
-
} else if (body && typeof body === "object") {
|
|
417
|
-
body = new Blob([JSON.stringify(body)], { type: "application/json" });
|
|
418
|
-
setContentType("application/json");
|
|
419
|
-
} else if (typeof body === "string") {
|
|
420
|
-
body = new Blob([body], { type: "text/plain" });
|
|
421
|
-
setContentType("text/plain");
|
|
422
|
-
}
|
|
423
|
-
return { body, headers };
|
|
424
|
-
}
|
|
425
393
|
|
|
426
394
|
const plusRegex = /\+/g;
|
|
427
395
|
function parseQuery(input) {
|
|
@@ -836,10 +804,6 @@ function createSilgiCore(event) {
|
|
|
836
804
|
async function silgiFetch(_request, options, context) {
|
|
837
805
|
const silgiCtx = useSilgi();
|
|
838
806
|
let request;
|
|
839
|
-
if (options) {
|
|
840
|
-
const wrapped = wrapBodyAndContentType(options);
|
|
841
|
-
options.headers = wrapped.headers;
|
|
842
|
-
}
|
|
843
807
|
if (typeof _request === "string") {
|
|
844
808
|
_request = substitutePathParams(_request, options?.pathParams);
|
|
845
809
|
let url = _request;
|
|
@@ -865,7 +829,7 @@ async function silgiFetch(_request, options, context) {
|
|
|
865
829
|
const silgiEvent = new _SilgiEvent(request, context);
|
|
866
830
|
let handlerRes;
|
|
867
831
|
try {
|
|
868
|
-
handlerRes =
|
|
832
|
+
handlerRes = handler(silgiEvent);
|
|
869
833
|
} catch (error) {
|
|
870
834
|
handlerRes = Promise.reject(error);
|
|
871
835
|
}
|