Spaces:
Running
Running
Initial deployment: ClinicalMatch AI v2.0 — FHIR R4 · MCP (9 tools) · A2A workflow · SHARP compliance · 100k synthetic patients · Neo4j graph · GraphRAG chatbot
59abb4f | // Hits every route once so webpack compiles them before the user navigates. | |
| // Run alongside the dev server: npm run prewarm | |
| const ROUTES = ["/", "/screening", "/recruitment", "/dashboard", "/map", "/graph"]; | |
| const BASE = process.env.NEXT_PUBLIC_API_URL?.replace("/api", "") ?? "http://localhost:3000"; | |
| async function waitForServer(url, retries = 30) { | |
| for (let i = 0; i < retries; i++) { | |
| try { | |
| const r = await fetch(url, { signal: AbortSignal.timeout(3000) }); | |
| if (r.ok || r.status < 500) return true; | |
| } catch {} | |
| await new Promise((r) => setTimeout(r, 2000)); | |
| } | |
| return false; | |
| } | |
| const base = "http://localhost:3000"; | |
| console.log("Waiting for dev server…"); | |
| const up = await waitForServer(base); | |
| if (!up) { console.error("Dev server never came up"); process.exit(1); } | |
| console.log("Pre-warming routes (this compiles each page bundle once):"); | |
| for (const route of ROUTES) { | |
| const start = Date.now(); | |
| try { | |
| await fetch(`${base}${route}`, { signal: AbortSignal.timeout(120_000) }); | |
| console.log(` ✓ ${route} — ${Date.now() - start}ms`); | |
| } catch (e) { | |
| console.log(` ✗ ${route} — ${e.message}`); | |
| } | |
| } | |
| console.log("All routes compiled. Navigation will now be instant."); | |