fix: temporarily disable WebSocket server to unblock deployment
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,9 @@ import { Hono } from "hono";
|
|||||||
import { cors } from "hono/cors";
|
import { cors } from "hono/cors";
|
||||||
import { logger } from "hono/logger";
|
import { logger } from "hono/logger";
|
||||||
import { registerRoutes } from "./routes";
|
import { registerRoutes } from "./routes";
|
||||||
import { shoppingWsHandlers } from "./ws/shopping-ws";
|
// import { shoppingWsHandlers } from "./ws/shopping-ws";
|
||||||
import { db, eq } from "@haushaltsApp/db";
|
// import { db, eq } from "@haushaltsApp/db";
|
||||||
import { session as sessionTable } from "@haushaltsApp/db/schema";
|
// import { session as sessionTable } from "@haushaltsApp/db/schema";
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
|
|
||||||
@@ -24,43 +24,43 @@ registerRoutes(app);
|
|||||||
|
|
||||||
// When running under Bun directly (not imported as a module for tests),
|
// When running under Bun directly (not imported as a module for tests),
|
||||||
// start Bun.serve with WebSocket support.
|
// start Bun.serve with WebSocket support.
|
||||||
if (typeof Bun !== "undefined" && !process.env.BUN_TEST) {
|
// if (typeof Bun !== "undefined" && !process.env.BUN_TEST) {
|
||||||
Bun.serve({
|
// Bun.serve({
|
||||||
port: Number(process.env.PORT ?? 3000),
|
// port: Number(process.env.PORT ?? 3000),
|
||||||
hostname: "0.0.0.0",
|
// hostname: "0.0.0.0",
|
||||||
websocket: shoppingWsHandlers,
|
// websocket: shoppingWsHandlers,
|
||||||
async fetch(req: Request, server) {
|
// async fetch(req: Request, server) {
|
||||||
const url = new URL(req.url);
|
// const url = new URL(req.url);
|
||||||
if (url.pathname === "/api/shopping-lists/ws") {
|
// if (url.pathname === "/api/shopping-lists/ws") {
|
||||||
const token = url.searchParams.get("token") ?? "";
|
// const token = url.searchParams.get("token") ?? "";
|
||||||
const householdId = url.searchParams.get("householdId") ?? "";
|
// const householdId = url.searchParams.get("householdId") ?? "";
|
||||||
|
|
||||||
if (!householdId) {
|
// if (!householdId) {
|
||||||
return new Response("Missing householdId", { status: 400 });
|
// return new Response("Missing householdId", { status: 400 });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const rawToken = token.includes(".") ? token.split(".")[0] : token;
|
// const rawToken = token.includes(".") ? token.split(".")[0] : token;
|
||||||
if (!rawToken) return new Response("Unauthorized", { status: 401 });
|
// if (!rawToken) return new Response("Unauthorized", { status: 401 });
|
||||||
|
|
||||||
const sessionRow = await db.query.session.findFirst({
|
// const sessionRow = await db.query.session.findFirst({
|
||||||
where: eq(sessionTable.token, rawToken),
|
// where: eq(sessionTable.token, rawToken),
|
||||||
with: { user: true },
|
// with: { user: true },
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (!sessionRow?.user || sessionRow.expiresAt < new Date()) {
|
// if (!sessionRow?.user || sessionRow.expiresAt < new Date()) {
|
||||||
return new Response("Unauthorized", { status: 401 });
|
// return new Response("Unauthorized", { status: 401 });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const upgraded = server.upgrade(req, {
|
// const upgraded = server.upgrade(req, {
|
||||||
data: { householdId, userId: sessionRow.user.id },
|
// data: { householdId, userId: sessionRow.user.id },
|
||||||
});
|
// });
|
||||||
if (upgraded) return undefined as unknown as Response;
|
// if (upgraded) return undefined as unknown as Response;
|
||||||
return new Response("WebSocket upgrade failed", { status: 400 });
|
// return new Response("WebSocket upgrade failed", { status: 400 });
|
||||||
}
|
// }
|
||||||
|
|
||||||
return app.fetch(req);
|
// return app.fetch(req);
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
Reference in New Issue
Block a user