Private
Public Access
1
0

Phase 5: Real-time updates via Socket.IO

Wire Socket.IO broadcast from all write API routes so board changes
propagate instantly to other connected clients. Add session-based auth
on socket connections, in-memory presence tracking, and a presence UI
in the board header showing who else is viewing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-26 00:03:13 -05:00
parent 095d9756a8
commit e61c549ddb
23 changed files with 408 additions and 120 deletions
+8 -1
View File
@@ -3,6 +3,7 @@ import type { RequestHandler } from './$types.js';
import { boardSchema } from '$lib/server/validation.js';
import { withTenant } from '$lib/server/rls.js';
import { requireBoardView, requireBoardEditor, requireBoardOwner } from '$lib/server/guards.js';
import { broadcast } from '$lib/server/realtime.js';
// Get single board with all columns and cards
export const GET: RequestHandler = async ({ params, locals }) => {
@@ -36,11 +37,14 @@ export const PATCH: RequestHandler = async ({ params, request, locals }) => {
});
});
const socketId = request.headers.get('X-Socket-ID');
broadcast(params.boardId, 'board:updated', { board: updated, socketId });
return json({ board: updated });
};
// Delete board
export const DELETE: RequestHandler = async ({ params, locals }) => {
export const DELETE: RequestHandler = async ({ params, request, locals }) => {
const tenant = locals.tenant;
if (!tenant) throw error(400, 'Unknown tenant');
@@ -49,5 +53,8 @@ export const DELETE: RequestHandler = async ({ params, locals }) => {
await tx.board.delete({ where: { id: params.boardId } });
});
const socketId = request.headers.get('X-Socket-ID');
broadcast(params.boardId, 'board:deleted', { boardId: params.boardId, socketId });
return json({ ok: true });
};