Comparing version 1.1.22 to 1.1.23
@@ -949,4 +949,4 @@ "use strict"; | ||
}; | ||
var createCookieJar = (set, store, initial) => { | ||
if (!set.cookie) set.cookie = {}; | ||
var createCookieJar = (set2, store, initial) => { | ||
if (!set2.cookie) set2.cookie = {}; | ||
return new Proxy(store, { | ||
@@ -957,3 +957,3 @@ get(_, key) { | ||
key, | ||
set.cookie, | ||
set2.cookie, | ||
Object.assign({}, initial ?? {}, store[key]) | ||
@@ -963,3 +963,3 @@ ); | ||
key, | ||
set.cookie, | ||
set2.cookie, | ||
Object.assign({}, initial) | ||
@@ -970,3 +970,3 @@ ); | ||
}; | ||
var parseCookie = async (set, cookieString, { | ||
var parseCookie = async (set2, cookieString, { | ||
secrets, | ||
@@ -976,3 +976,3 @@ sign, | ||
} = {}) => { | ||
if (!cookieString) return createCookieJar(set, {}, initial); | ||
if (!cookieString) return createCookieJar(set2, {}, initial); | ||
const isStringKey = typeof secrets === "string"; | ||
@@ -1008,3 +1008,3 @@ if (sign && sign !== true && !Array.isArray(sign)) sign = [sign]; | ||
} | ||
return createCookieJar(set, jar, initial); | ||
return createCookieJar(set2, jar, initial); | ||
}; | ||
@@ -1011,0 +1011,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -920,15 +920,15 @@ "use strict"; | ||
}; | ||
var handleFile = (response, set) => { | ||
var handleFile = (response, set2) => { | ||
const size = response.size; | ||
if (!set && size || size && set && set.status !== 206 && set.status !== 304 && set.status !== 412 && set.status !== 416) { | ||
if (set && isNotEmpty(set.headers)) { | ||
if (set.headers instanceof Headers) { | ||
if (!set2 && size || size && set2 && set2.status !== 206 && set2.status !== 304 && set2.status !== 412 && set2.status !== 416) { | ||
if (set2 && isNotEmpty(set2.headers)) { | ||
if (set2.headers instanceof Headers) { | ||
if (hasHeaderShorthand) | ||
set.headers = set.headers.toJSON(); | ||
set2.headers = set2.headers.toJSON(); | ||
else | ||
for (const [key, value] of set.headers.entries()) | ||
if (key in set.headers) set.headers[key] = value; | ||
for (const [key, value] of set2.headers.entries()) | ||
if (key in set2.headers) set2.headers[key] = value; | ||
} | ||
return new Response(response, { | ||
status: set.status, | ||
status: set2.status, | ||
headers: Object.assign( | ||
@@ -939,3 +939,3 @@ { | ||
}, | ||
set.headers | ||
set2.headers | ||
) | ||
@@ -968,3 +968,3 @@ }); | ||
if (!cookies || !isNotEmpty(cookies)) return void 0; | ||
const set = []; | ||
const set2 = []; | ||
for (const [key, property] of Object.entries(cookies)) { | ||
@@ -974,3 +974,3 @@ if (!key || !property) continue; | ||
if (value === void 0 || value === null) continue; | ||
set.push( | ||
set2.push( | ||
(0, import_cookie2.serialize)( | ||
@@ -983,11 +983,11 @@ key, | ||
} | ||
if (set.length === 0) return void 0; | ||
if (set.length === 1) return set[0]; | ||
return set; | ||
if (set2.length === 0) return void 0; | ||
if (set2.length === 1) return set2[0]; | ||
return set2; | ||
}; | ||
var handleStream = async (generator, set, request) => { | ||
var handleStream = async (generator, set2, request) => { | ||
let init = generator.next(); | ||
if (init instanceof Promise) init = await init; | ||
if (init.done) { | ||
if (set) return mapResponse(init.value, set, request); | ||
if (set2) return mapResponse(init.value, set2, request); | ||
return mapCompactResponse(init.value, request); | ||
@@ -1042,3 +1042,3 @@ } | ||
{ | ||
...set, | ||
...set2, | ||
headers: { | ||
@@ -1048,3 +1048,3 @@ // Manually set transfer-encoding for direct response, eg. app.handle, eden | ||
"content-type": "text/event-stream; charset=utf-8", | ||
...set?.headers | ||
...set2?.headers | ||
} | ||
@@ -1069,18 +1069,18 @@ } | ||
} | ||
var mapResponse = (response, set, request) => { | ||
if (isNotEmpty(set.headers) || set.status !== 200 || set.redirect || set.cookie) { | ||
if (typeof set.status === "string") set.status = StatusMap[set.status]; | ||
if (set.redirect) { | ||
set.headers.Location = set.redirect; | ||
if (!set.status || set.status < 300 || set.status >= 400) | ||
set.status = 302; | ||
var mapResponse = (response, set2, request) => { | ||
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.redirect || set2.cookie) { | ||
if (typeof set2.status === "string") set2.status = StatusMap[set2.status]; | ||
if (set2.redirect) { | ||
set2.headers.Location = set2.redirect; | ||
if (!set2.status || set2.status < 300 || set2.status >= 400) | ||
set2.status = 302; | ||
} | ||
if (set.cookie && isNotEmpty(set.cookie)) { | ||
const cookie = serializeCookie(set.cookie); | ||
if (cookie) set.headers["set-cookie"] = cookie; | ||
if (set2.cookie && isNotEmpty(set2.cookie)) { | ||
const cookie = serializeCookie(set2.cookie); | ||
if (cookie) set2.headers["set-cookie"] = cookie; | ||
} | ||
if (set.headers["set-cookie"] && Array.isArray(set.headers["set-cookie"])) { | ||
set.headers = parseSetCookies( | ||
new Headers(set.headers), | ||
set.headers["set-cookie"] | ||
if (set2.headers["set-cookie"] && Array.isArray(set2.headers["set-cookie"])) { | ||
set2.headers = parseSetCookies( | ||
new Headers(set2.headers), | ||
set2.headers["set-cookie"] | ||
); | ||
@@ -1090,21 +1090,21 @@ } | ||
case "String": | ||
return new Response(response, set); | ||
return new Response(response, set2); | ||
case "Blob": | ||
return handleFile(response, set); | ||
return handleFile(response, set2); | ||
case "Array": | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "Object": | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "ElysiaCustomStatusResponse": | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
); | ||
case "ReadableStream": | ||
if (!set.headers["content-type"]?.startsWith( | ||
if (!set2.headers["content-type"]?.startsWith( | ||
"text/event-stream" | ||
)) | ||
set.headers["content-type"] = "text/event-stream; charset=utf-8"; | ||
set2.headers["content-type"] = "text/event-stream; charset=utf-8"; | ||
request?.signal.addEventListener( | ||
@@ -1124,15 +1124,15 @@ "abort", | ||
response, | ||
set | ||
set2 | ||
); | ||
case void 0: | ||
if (!response) return new Response("", set); | ||
return Response.json(response, set); | ||
if (!response) return new Response("", set2); | ||
return Response.json(response, set2); | ||
case "Response": | ||
let isCookieSet = false; | ||
if (set.headers instanceof Headers) | ||
for (const key of set.headers.keys()) { | ||
if (set2.headers instanceof Headers) | ||
for (const key of set2.headers.keys()) { | ||
if (key === "set-cookie") { | ||
if (isCookieSet) continue; | ||
isCookieSet = true; | ||
for (const cookie of set.headers.getSetCookie()) { | ||
for (const cookie of set2.headers.getSetCookie()) { | ||
; | ||
@@ -1147,17 +1147,17 @@ response.headers.append( | ||
key, | ||
set.headers?.get(key) ?? "" | ||
set2.headers?.get(key) ?? "" | ||
); | ||
} | ||
else | ||
for (const key in set.headers) | ||
for (const key in set2.headers) | ||
response.headers.append( | ||
key, | ||
set.headers[key] | ||
set2.headers[key] | ||
); | ||
if (response.status !== set.status) | ||
set.status = response.status; | ||
if (response.status !== set2.status) | ||
set2.status = response.status; | ||
if (response.headers.get("transfer-encoding") === "chunked") | ||
return handleStream( | ||
streamResponse(response), | ||
set, | ||
set2, | ||
request | ||
@@ -1167,9 +1167,9 @@ ); | ||
case "Error": | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
case "Promise": | ||
return response.then( | ||
(x) => mapResponse(x, set) | ||
(x) => mapResponse(x, set2) | ||
); | ||
case "Function": | ||
return mapResponse(response(), set); | ||
return mapResponse(response(), set2); | ||
case "Number": | ||
@@ -1179,19 +1179,19 @@ case "Boolean": | ||
response.toString(), | ||
set | ||
set2 | ||
); | ||
case "Cookie": | ||
if (response instanceof Cookie) | ||
return new Response(response.value, set); | ||
return new Response(response?.toString(), set); | ||
return new Response(response.value, set2); | ||
return new Response(response?.toString(), set2); | ||
case "FormData": | ||
return new Response(response, set); | ||
return new Response(response, set2); | ||
default: | ||
if (response instanceof Response) { | ||
let isCookieSet2 = false; | ||
if (set.headers instanceof Headers) | ||
for (const key of set.headers.keys()) { | ||
if (set2.headers instanceof Headers) | ||
for (const key of set2.headers.keys()) { | ||
if (key === "set-cookie") { | ||
if (isCookieSet2) continue; | ||
isCookieSet2 = true; | ||
for (const cookie of set.headers.getSetCookie()) { | ||
for (const cookie of set2.headers.getSetCookie()) { | ||
; | ||
@@ -1206,27 +1206,27 @@ response.headers.append( | ||
key, | ||
set.headers?.get(key) ?? "" | ||
set2.headers?.get(key) ?? "" | ||
); | ||
} | ||
else | ||
for (const key in set.headers) | ||
for (const key in set2.headers) | ||
response.headers.append( | ||
key, | ||
set.headers[key] | ||
set2.headers[key] | ||
); | ||
if (hasHeaderShorthand) | ||
set.headers = response.headers.toJSON(); | ||
set2.headers = response.headers.toJSON(); | ||
else | ||
for (const [key, value] of response.headers.entries()) | ||
if (key in set.headers) set.headers[key] = value; | ||
if (key in set2.headers) set2.headers[key] = value; | ||
return response; | ||
} | ||
if (response instanceof Promise) | ||
return response.then((x) => mapResponse(x, set)); | ||
return response.then((x) => mapResponse(x, set2)); | ||
if (response instanceof Error) | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
if (response instanceof ElysiaCustomStatusResponse) { | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
@@ -1236,17 +1236,19 @@ ); | ||
if (typeof response?.next === "function") | ||
return handleStream(response, set, request); | ||
if ("toResponse" in response) | ||
return mapResponse(response.toResponse(), set); | ||
return handleStream(response, set2, request); | ||
if (typeof response?.then === "function") | ||
return response.then((x) => mapResponse(x, set2)); | ||
if (typeof response?.toResponse === "function") | ||
return mapResponse(response.toResponse(), set2); | ||
if ("charCodeAt" in response) { | ||
const code = response.charCodeAt(0); | ||
if (code === 123 || code === 91) { | ||
if (!set.headers["Content-Type"]) | ||
set.headers["Content-Type"] = "application/json"; | ||
if (!set2.headers["Content-Type"]) | ||
set2.headers["Content-Type"] = "application/json"; | ||
return new Response( | ||
JSON.stringify(response), | ||
set | ||
set2 | ||
); | ||
} | ||
} | ||
return new Response(response, set); | ||
return new Response(response, set2); | ||
} | ||
@@ -1258,12 +1260,12 @@ } else | ||
case "Blob": | ||
return handleFile(response, set); | ||
return handleFile(response, set2); | ||
case "Array": | ||
return Response.json(response); | ||
case "Object": | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "ElysiaCustomStatusResponse": | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
@@ -1300,3 +1302,3 @@ ); | ||
streamResponse(response), | ||
set, | ||
set2, | ||
request | ||
@@ -1306,3 +1308,3 @@ ); | ||
case "Error": | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
case "Promise": | ||
@@ -1321,17 +1323,17 @@ return response.then((x) => { | ||
if (response instanceof Cookie) | ||
return new Response(response.value, set); | ||
return new Response(response?.toString(), set); | ||
return new Response(response.value, set2); | ||
return new Response(response?.toString(), set2); | ||
case "FormData": | ||
return new Response(response, set); | ||
return new Response(response, set2); | ||
default: | ||
if (response instanceof Response) return response; | ||
if (response instanceof Promise) | ||
return response.then((x) => mapResponse(x, set)); | ||
return response.then((x) => mapResponse(x, set2)); | ||
if (response instanceof Error) | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
if (response instanceof ElysiaCustomStatusResponse) { | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
@@ -1341,13 +1343,15 @@ ); | ||
if (typeof response?.next === "function") | ||
return handleStream(response, set, request); | ||
if ("toResponse" in response) | ||
return mapResponse(response.toResponse(), set); | ||
return handleStream(response, set2, request); | ||
if (typeof response?.then === "function") | ||
return response.then((x) => mapResponse(x, set2)); | ||
if (typeof response?.toResponse === "function") | ||
return mapResponse(response.toResponse(), set2); | ||
if ("charCodeAt" in response) { | ||
const code = response.charCodeAt(0); | ||
if (code === 123 || code === 91) { | ||
if (!set.headers["Content-Type"]) | ||
set.headers["Content-Type"] = "application/json"; | ||
if (!set2.headers["Content-Type"]) | ||
set2.headers["Content-Type"] = "application/json"; | ||
return new Response( | ||
JSON.stringify(response), | ||
set | ||
set2 | ||
); | ||
@@ -1359,41 +1363,41 @@ } | ||
}; | ||
var mapEarlyResponse = (response, set, request) => { | ||
var mapEarlyResponse = (response, set2, request) => { | ||
if (response === void 0 || response === null) return; | ||
if (isNotEmpty(set.headers) || set.status !== 200 || set.redirect || set.cookie) { | ||
if (typeof set.status === "string") set.status = StatusMap[set.status]; | ||
if (set.redirect) { | ||
set.headers.Location = set.redirect; | ||
if (!set.status || set.status < 300 || set.status >= 400) | ||
set.status = 302; | ||
if (isNotEmpty(set2.headers) || set2.status !== 200 || set2.redirect || set2.cookie) { | ||
if (typeof set2.status === "string") set2.status = StatusMap[set2.status]; | ||
if (set2.redirect) { | ||
set2.headers.Location = set2.redirect; | ||
if (!set2.status || set2.status < 300 || set2.status >= 400) | ||
set2.status = 302; | ||
} | ||
if (set.cookie && isNotEmpty(set.cookie)) { | ||
const cookie = serializeCookie(set.cookie); | ||
if (cookie) set.headers["set-cookie"] = cookie; | ||
if (set2.cookie && isNotEmpty(set2.cookie)) { | ||
const cookie = serializeCookie(set2.cookie); | ||
if (cookie) set2.headers["set-cookie"] = cookie; | ||
} | ||
if (set.headers["set-cookie"] && Array.isArray(set.headers["set-cookie"])) | ||
set.headers = parseSetCookies( | ||
new Headers(set.headers), | ||
set.headers["set-cookie"] | ||
if (set2.headers["set-cookie"] && Array.isArray(set2.headers["set-cookie"])) | ||
set2.headers = parseSetCookies( | ||
new Headers(set2.headers), | ||
set2.headers["set-cookie"] | ||
); | ||
switch (response?.constructor?.name) { | ||
case "String": | ||
return new Response(response, set); | ||
return new Response(response, set2); | ||
case "Blob": | ||
return handleFile(response, set); | ||
return handleFile(response, set2); | ||
case "Array": | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "Object": | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "ElysiaCustomStatusResponse": | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapEarlyResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
); | ||
case "ReadableStream": | ||
if (!set.headers["content-type"]?.startsWith( | ||
if (!set2.headers["content-type"]?.startsWith( | ||
"text/event-stream" | ||
)) | ||
set.headers["content-type"] = "text/event-stream; charset=utf-8"; | ||
set2.headers["content-type"] = "text/event-stream; charset=utf-8"; | ||
request?.signal.addEventListener( | ||
@@ -1413,15 +1417,15 @@ "abort", | ||
response, | ||
set | ||
set2 | ||
); | ||
case void 0: | ||
if (!response) return; | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "Response": | ||
let isCookieSet = false; | ||
if (set.headers instanceof Headers) | ||
for (const key of set.headers.keys()) { | ||
if (set2.headers instanceof Headers) | ||
for (const key of set2.headers.keys()) { | ||
if (key === "set-cookie") { | ||
if (isCookieSet) continue; | ||
isCookieSet = true; | ||
for (const cookie of set.headers.getSetCookie()) { | ||
for (const cookie of set2.headers.getSetCookie()) { | ||
; | ||
@@ -1436,17 +1440,17 @@ response.headers.append( | ||
key, | ||
set.headers?.get(key) ?? "" | ||
set2.headers?.get(key) ?? "" | ||
); | ||
} | ||
else | ||
for (const key in set.headers) | ||
for (const key in set2.headers) | ||
response.headers.append( | ||
key, | ||
set.headers[key] | ||
set2.headers[key] | ||
); | ||
if (response.status !== set.status) | ||
set.status = response.status; | ||
if (response.status !== set2.status) | ||
set2.status = response.status; | ||
if (response.headers.get("transfer-encoding") === "chunked") | ||
return handleStream( | ||
streamResponse(response), | ||
set, | ||
set2, | ||
request | ||
@@ -1457,9 +1461,9 @@ ); | ||
return response.then((x) => { | ||
const r = mapEarlyResponse(x, set); | ||
const r = mapEarlyResponse(x, set2); | ||
if (r !== void 0) return r; | ||
}); | ||
case "Error": | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
case "Function": | ||
return mapEarlyResponse(response(), set); | ||
return mapEarlyResponse(response(), set2); | ||
case "Number": | ||
@@ -1469,3 +1473,3 @@ case "Boolean": | ||
response.toString(), | ||
set | ||
set2 | ||
); | ||
@@ -1476,13 +1480,13 @@ case "FormData": | ||
if (response instanceof Cookie) | ||
return new Response(response.value, set); | ||
return new Response(response?.toString(), set); | ||
return new Response(response.value, set2); | ||
return new Response(response?.toString(), set2); | ||
default: | ||
if (response instanceof Response) { | ||
let isCookieSet2 = false; | ||
if (set.headers instanceof Headers) | ||
for (const key of set.headers.keys()) { | ||
if (set2.headers instanceof Headers) | ||
for (const key of set2.headers.keys()) { | ||
if (key === "set-cookie") { | ||
if (isCookieSet2) continue; | ||
isCookieSet2 = true; | ||
for (const cookie of set.headers.getSetCookie()) { | ||
for (const cookie of set2.headers.getSetCookie()) { | ||
; | ||
@@ -1497,24 +1501,24 @@ response.headers.append( | ||
key, | ||
set.headers?.get(key) ?? "" | ||
set2.headers?.get(key) ?? "" | ||
); | ||
} | ||
else | ||
for (const key in set.headers) | ||
for (const key in set2.headers) | ||
response.headers.append( | ||
key, | ||
set.headers[key] | ||
set2.headers[key] | ||
); | ||
if (response.status !== set.status) | ||
set.status = response.status; | ||
if (response.status !== set2.status) | ||
set2.status = response.status; | ||
return response; | ||
} | ||
if (response instanceof Promise) | ||
return response.then((x) => mapEarlyResponse(x, set)); | ||
return response.then((x) => mapEarlyResponse(x, set2)); | ||
if (response instanceof Error) | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
if (response instanceof ElysiaCustomStatusResponse) { | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapEarlyResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
@@ -1524,17 +1528,19 @@ ); | ||
if (typeof response?.next === "function") | ||
return handleStream(response, set, request); | ||
if ("toResponse" in response) | ||
return mapEarlyResponse(response.toResponse(), set); | ||
return handleStream(response, set2, request); | ||
if (typeof response?.then === "function") | ||
return response.then((x) => mapEarlyResponse(x, set2)); | ||
if (typeof response?.toResponse === "function") | ||
return mapEarlyResponse(response.toResponse(), set2); | ||
if ("charCodeAt" in response) { | ||
const code = response.charCodeAt(0); | ||
if (code === 123 || code === 91) { | ||
if (!set.headers["Content-Type"]) | ||
set.headers["Content-Type"] = "application/json"; | ||
if (!set2.headers["Content-Type"]) | ||
set2.headers["Content-Type"] = "application/json"; | ||
return new Response( | ||
JSON.stringify(response), | ||
set | ||
set2 | ||
); | ||
} | ||
} | ||
return new Response(response, set); | ||
return new Response(response, set2); | ||
} | ||
@@ -1546,12 +1552,12 @@ } else | ||
case "Blob": | ||
return handleFile(response, set); | ||
return handleFile(response, set2); | ||
case "Array": | ||
return Response.json(response); | ||
case "Object": | ||
return Response.json(response, set); | ||
return Response.json(response, set2); | ||
case "ElysiaCustomStatusResponse": | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapEarlyResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
@@ -1592,7 +1598,7 @@ ); | ||
return response.then((x) => { | ||
const r = mapEarlyResponse(x, set); | ||
const r = mapEarlyResponse(x, set2); | ||
if (r !== void 0) return r; | ||
}); | ||
case "Error": | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
case "Function": | ||
@@ -1605,4 +1611,4 @@ return mapCompactResponse(response(), request); | ||
if (response instanceof Cookie) | ||
return new Response(response.value, set); | ||
return new Response(response?.toString(), set); | ||
return new Response(response.value, set2); | ||
return new Response(response?.toString(), set2); | ||
case "FormData": | ||
@@ -1613,10 +1619,10 @@ return new Response(response); | ||
if (response instanceof Promise) | ||
return response.then((x) => mapEarlyResponse(x, set)); | ||
return response.then((x) => mapEarlyResponse(x, set2)); | ||
if (response instanceof Error) | ||
return errorToResponse(response, set); | ||
return errorToResponse(response, set2); | ||
if (response instanceof ElysiaCustomStatusResponse) { | ||
set.status = response.code; | ||
set2.status = response.code; | ||
return mapEarlyResponse( | ||
response.response, | ||
set, | ||
set2, | ||
request | ||
@@ -1626,13 +1632,15 @@ ); | ||
if (typeof response?.next === "function") | ||
return handleStream(response, set, request); | ||
if ("toResponse" in response) | ||
return mapEarlyResponse(response.toResponse(), set); | ||
return handleStream(response, set2, request); | ||
if (typeof response?.then === "function") | ||
return response.then((x) => mapEarlyResponse(x, set2)); | ||
if (typeof response?.toResponse === "function") | ||
return mapEarlyResponse(response.toResponse(), set2); | ||
if ("charCodeAt" in response) { | ||
const code = response.charCodeAt(0); | ||
if (code === 123 || code === 91) { | ||
if (!set.headers["Content-Type"]) | ||
set.headers["Content-Type"] = "application/json"; | ||
if (!set2.headers["Content-Type"]) | ||
set2.headers["Content-Type"] = "application/json"; | ||
return new Response( | ||
JSON.stringify(response), | ||
set | ||
set2 | ||
); | ||
@@ -1722,3 +1730,5 @@ } | ||
return handleStream(response, void 0, request); | ||
if ("toResponse" in response) | ||
if (typeof response?.then === "function") | ||
return response.then((x) => mapResponse(x, set)); | ||
if (typeof response?.toResponse === "function") | ||
return mapCompactResponse(response.toResponse()); | ||
@@ -1738,3 +1748,3 @@ if ("charCodeAt" in response) { | ||
}; | ||
var errorToResponse = (error, set) => new Response( | ||
var errorToResponse = (error, set2) => new Response( | ||
JSON.stringify({ | ||
@@ -1746,4 +1756,4 @@ name: error?.name, | ||
{ | ||
status: set?.status !== 200 ? set?.status ?? 500 : 500, | ||
headers: set?.headers | ||
status: set2?.status !== 200 ? set2?.status ?? 500 : 500, | ||
headers: set2?.headers | ||
} | ||
@@ -1750,0 +1760,0 @@ ); |
{ | ||
"name": "elysia", | ||
"description": "Ergonomic Framework for Human", | ||
"version": "1.1.22", | ||
"version": "1.1.23", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "saltyAom", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2648177
56271