Migrate webapp to SvelteKit (Svelte 5 + adapter-node) #4
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lz/agent-nexus#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Migrate the entire Nexus webapp from "Fastify backend (
nexus/src/) + vanilla-TS SPA (nexus/web/)" to SvelteKit (Svelte 5 + adapter-node). Same routes, same flows, same UI. No behavior changes from the operator's perspective.Hard constraints (don't skip)
hooks.server.tswith a path-prefix check on/api/*+ a public allowlist (/api/state,/api/auth/setup,/api/auth/unlock). Replacesnexus/src/auth/guard.tsand everyapp.addHook('preHandler', requireUnlocked). Audit each ported route to confirm it lands on the right side of the gate.event.cookies.set(name, val, { path: '/', sameSite: 'lax', httpOnly: true, secure: false, maxAge: ttl }). SvelteKit's defaults differ from@fastify/cookieand silently dropping the session on redirect is the most likely regression.PORTenv).pnpm testmust stay green — the existing vitest suites should survive with only import-path updates, since the pure-logic modules (auth/session.ts,auth/vault-store.ts,workers/service.ts,workers/docker.ts,sessions/service.ts,connections/service.ts,crypto/*) move undersrc/lib/server/without code changes.Verification (issue is not done until all pass)
pnpm install+pnpm typecheck+pnpm test+pnpm buildall clean.docker compose down -v && docker compose up -d --build(new Dockerfile uses adapter-node).curl -X POST /api/lockand/api/workers/<id>/start(bodyless POSTs — Fastify had a workaround atnexus/src/server.ts:51-56; verify SvelteKit's lazy body read covers this).Gotchas
--remote-control NAMEfromnexus/src/sessions/service.ts:checkSessionHealth. AGENTS.md fact #5 explains why — one process matching can satisfy every session's probe otherwise./api/lock, workspacestart/stop) must not error when there's no Content-Type.main()inserver.ts:23. Move it to wherever you boot singletons (likelysrc/lib/server/singletons.tsat module init) so it runs before any route handler hits the db.SIGTERM/SIGINTlisteners yourself (close db, destroySessionStore).needs-provider, withautofocus: true) and as a regular nav target. Keep one component, take an optionalautofocusprop.refresh(): Promise<void>callback that every current view receives — replace withinvalidateAll()from$app/navigation, optionally exposed viasetContext('refresh', ...)so children don't prop-drill.References
nexus/src/server.tsnexus/web/src/main.tsnexus/web/src/views/*.tsnexus/src/auth/guard.ts,nexus/src/auth/routes.ts