trails/apps/planner/server.ts
Ullrich Schäfer 464ba0f64d
Add Planner session management with Yjs WebSocket (#1)
- Yjs WebSocket server at /sync/:sessionId for real-time collaboration
- Session creation API (POST /api/sessions) with optional GPX initialization
- Session join page with Planner layout (header, map area, sidebar)
- In-memory session store (PostgreSQL persistence deferred to infra setup)
- Custom production server entry with WebSocket upgrade handling
- Vite path aliases (~/) for clean imports
- Fix tsconfig for apps: noEmit, exclude build dir

Tasks completed: 4.1, 4.3, 4.4, 4.5
Deferred: 4.2 (PostgreSQL), 4.6-4.8 (need client-side Yjs from Group 6)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 13:26:03 +01:00

21 lines
621 B
TypeScript

import { createRequestHandler } from "@react-router/node";
import { createServer } from "node:http";
import { setupYjsWebSocket } from "./app/lib/yjs-server";
const port = Number(process.env.PORT ?? 3001);
const handler = createRequestHandler(
// @ts-expect-error - build output types
await import("./build/server/index.js"),
);
const server = createServer((req, res) => {
handler(req, res);
});
setupYjsWebSocket(server);
server.listen(port, () => {
console.log(`Planner server listening on http://localhost:${port}`);
console.log(`Yjs WebSocket available at ws://localhost:${port}/sync/:sessionId`);
});