Files
GoClaw/server/index.ts
bboxwtf 62cedcdba5 feat(phase17): close technical debt — Dashboard real data, index.ts @deprecated, ADR streaming/auth
- Dashboard.tsx: removed 3 hardcoded mock constants (NODES/AGENTS/ACTIVITY_LOG)
  - Swarm Nodes panel: real data from trpc.nodes.list (swarm nodes or containers)
  - Container stats: live CPU%/MEM from trpc.nodes.stats, rendered as progress bars
  - Active Agents panel: real agents from trpc.agents.list with isActive/isSystem/model/role
  - Activity Feed: generated from active agents list (live agent names, models, timestamps)
  - Metric cards: real counts from trpc.dashboard.stats (uptime, nodes, agents, gateway)
  - All 3 panels have loading state (Loader2 spinner) and empty/error state
  - Hero banner subtitle uses real stats.nodes and stats.agents counts
  - Cluster Topology footer shows real uptime from dashboard.stats

- server/index.ts: documented as @deprecated legacy static-only entry point
  - Added JSDoc block explaining this file is NOT the production server
  - Points to server/_core/index.ts as the real server with tRPC/OAuth/seed
  - Added console.log WARNING on startup to prevent accidental use
  - File retained as historical artefact per Phase 17 decision

- todo.md: Phase 16 debt items closed as [x], Phase 17 section added
  - ADR-001: Streaming LLM — status DEFERRED, Phase 18 plan documented
    (Go Gateway stream:true + tRPC subscription + Chat.tsx EventSource)
  - ADR-002: Authentication — status ACCEPTED as internal tool
    (OAuth already partial; protectedProcedure path documented for future)
  - Phase 9 routers.ts orchestrator migration verified as complete
2026-03-21 02:47:59 +00:00

58 lines
2.0 KiB
TypeScript

/**
* server/index.ts — LEGACY STATIC-ONLY ENTRY POINT
*
* @deprecated This file is NOT used in production or development.
*
* The real application server is: server/_core/index.ts
* - Registers tRPC router (/api/trpc)
* - Registers OAuth routes (/api/oauth/callback)
* - Runs Vite middleware in development
* - Serves pre-built static assets in production (dist/public)
* - Seeds default agents on startup
*
* This file was the original minimal static server created before
* tRPC integration. It has NO tRPC routes, NO OAuth, NO seed logic.
*
* Build entrypoint (tsconfig/vite.config) → server/_core/index.ts
* Dockerfile CMD → node dist/index.js (compiled from _core/index.ts)
*
* ⚠️ DO NOT add business logic here.
* DO NOT run this file directly in production.
* It is kept as a historical artefact and may be removed in a future
* cleanup phase (see todo.md Phase 17 — technical debt).
*/
import express from "express";
import { createServer } from "http";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function startServer() {
const app = express();
const server = createServer(app);
// Serve static files from dist/public in production
const staticPath =
process.env.NODE_ENV === "production"
? path.resolve(__dirname, "public")
: path.resolve(__dirname, "..", "dist", "public");
app.use(express.static(staticPath));
// Handle client-side routing — serve index.html for all routes
app.get("*", (_req, res) => {
res.sendFile(path.join(staticPath, "index.html"));
});
const port = process.env.PORT || 3000;
server.listen(port, () => {
console.log(`[LEGACY] Static-only server running on http://localhost:${port}/`);
console.log("[LEGACY] WARNING: This server has no tRPC routes. Use server/_core/index.ts instead.");
});
}
startServer().catch(console.error);