bxo 0.0.5-dev.30 → 0.0.5-dev.31
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/index.ts +1 -39
- package/package.json +1 -1
package/index.ts
CHANGED
@@ -636,15 +636,6 @@ export default class BXO {
|
|
636
636
|
// Execute route handler
|
637
637
|
let response = await route.handler(ctx);
|
638
638
|
|
639
|
-
// If handler returned a Response, expose its status and headers to hooks
|
640
|
-
if (response instanceof Response) {
|
641
|
-
if (ctx.set.status === undefined) {
|
642
|
-
ctx.set.status = response.status;
|
643
|
-
}
|
644
|
-
const existingHeaders = Object.fromEntries(response.headers);
|
645
|
-
ctx.set.headers = { ...(existingHeaders || {}), ...(ctx.set.headers || {}) };
|
646
|
-
}
|
647
|
-
|
648
639
|
// Run global onResponse hook
|
649
640
|
if (this.hooks.onResponse) {
|
650
641
|
response = await this.hooks.onResponse(ctx, response, this) || response;
|
@@ -692,36 +683,7 @@ export default class BXO {
|
|
692
683
|
|
693
684
|
// Convert response to Response object
|
694
685
|
if (response instanceof Response) {
|
695
|
-
|
696
|
-
let responseHeaders: Record<string, string> = {
|
697
|
-
...Object.fromEntries(response.headers),
|
698
|
-
...(ctx.set.headers || {})
|
699
|
-
};
|
700
|
-
|
701
|
-
// Handle cookies if any are set
|
702
|
-
if (ctx.set.cookies && ctx.set.cookies.length > 0) {
|
703
|
-
const cookieHeaders = ctx.set.cookies.map(cookie => {
|
704
|
-
let cookieString = `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`;
|
705
|
-
|
706
|
-
if (cookie.domain) cookieString += `; Domain=${cookie.domain}`;
|
707
|
-
if (cookie.path) cookieString += `; Path=${cookie.path}`;
|
708
|
-
if (cookie.expires) cookieString += `; Expires=${cookie.expires.toUTCString()}`;
|
709
|
-
if (cookie.maxAge) cookieString += `; Max-Age=${cookie.maxAge}`;
|
710
|
-
if (cookie.secure) cookieString += `; Secure`;
|
711
|
-
if (cookie.httpOnly) cookieString += `; HttpOnly`;
|
712
|
-
if (cookie.sameSite) cookieString += `; SameSite=${cookie.sameSite}`;
|
713
|
-
|
714
|
-
return cookieString;
|
715
|
-
});
|
716
|
-
|
717
|
-
// Add Set-Cookie headers
|
718
|
-
cookieHeaders.forEach((cookieHeader, index) => {
|
719
|
-
responseHeaders[index === 0 ? 'Set-Cookie' : `Set-Cookie-${index}`] = cookieHeader;
|
720
|
-
});
|
721
|
-
}
|
722
|
-
|
723
|
-
const mergedStatus = ctx.set.status || response.status || 200;
|
724
|
-
return new Response(response.body, { status: mergedStatus, headers: responseHeaders });
|
686
|
+
return response;
|
725
687
|
}
|
726
688
|
|
727
689
|
// Handle File response (like Elysia)
|