From b71d32da5e4c3fe85f439e1964a45ef5e2807eea Mon Sep 17 00:00:00 2001 From: dtoro Date: Thu, 12 Mar 2026 21:10:00 +0100 Subject: [PATCH] fix: remove backend placeholders --- README.md | 11 +---- backend/package.json | 2 +- backend/src/index.js | 68 +------------------------- frontend/src/app/canvas/CanvasPage.tsx | 15 ------ frontend/vite.config.ts | 8 --- 5 files changed, 4 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index f9c8587..8fe4f59 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ cd frontend && npm install && npm run dev # → http://localhost:3000 ``` -**Frontend + backend** (so the app can show “Backend API: N todos”): +**Frontend + backend** (for AI agent and health): ```bash # Terminal 1 – backend @@ -45,7 +45,7 @@ cd backend && npm install && npm run dev # Terminal 2 – frontend cd frontend && npm install && npm run dev -# → http://localhost:3000 (Vite proxies /api/todos to backend) +# → http://localhost:3000 (Vite proxies /api/* and /health to backend) ``` --- @@ -89,16 +89,9 @@ For self-hosting (e.g. Tailscale/HTTPS): set `CORS_ORIGIN` to your frontend URL; | Method | Path | Description | |--------|------|-------------| -| GET | `/api/todos` | List all todos. | -| GET | `/api/todos/:id` | Get one todo. | -| POST | `/api/todos` | Create (`{ "title": "...", "completed": false }`). | -| PUT | `/api/todos/:id` | Update. | -| DELETE | `/api/todos/:id` | Delete. | | GET | `/health` | Health check (e.g. for Docker). | | POST | `/api/agent` | Run AI agent; body `{ "prompt", "context?", "contextNodes?" }` → `{ "markdown" }`. | -Data is in-memory (resets on restart). Add a JSON file or DB later if needed. - --- ## Agent node (local LLM or OpenAI) diff --git a/backend/package.json b/backend/package.json index b7ee66e..855ea82 100644 --- a/backend/package.json +++ b/backend/package.json @@ -2,7 +2,7 @@ "name": "zui-backend", "version": "1.0.0", "private": true, - "description": "Minimal Express API for Zui (todos CRUD, no DB)", + "description": "Minimal Express API for Zui (agent, health; no DB)", "main": "src/index.js", "scripts": { "start": "node src/index.js", diff --git a/backend/src/index.js b/backend/src/index.js index d56adac..a09da7b 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,5 +1,5 @@ /** - * Minimal Express API: /api/todos CRUD (in-memory). + * Minimal Express API: /api/agent, /health. * No DB, no auth. CORS allowed for frontend. Production-ready env (PORT, CORS_ORIGIN). */ @@ -14,72 +14,6 @@ const app = express() app.use(cors({ origin: CORS_ORIGIN })) app.use(express.json()) -// In-memory store (replace with JSON file or DB later) -let todos = [ - { id: '1', title: 'Sample todo', completed: false }, - { id: '2', title: 'Another item', completed: true }, -] -let nextId = 3 - -/** GET /api/todos — list all */ -app.get('/api/todos', (req, res) => { - try { - res.json(todos) - } catch (err) { - res.status(500).json({ error: err.message }) - } -}) - -/** GET /api/todos/:id — get one */ -app.get('/api/todos/:id', (req, res) => { - try { - const todo = todos.find((t) => t.id === req.params.id) - if (!todo) return res.status(404).json({ error: 'Not found' }) - res.json(todo) - } catch (err) { - res.status(500).json({ error: err.message }) - } -}) - -/** POST /api/todos — create */ -app.post('/api/todos', (req, res) => { - try { - const { title, completed } = req.body ?? {} - const id = String(nextId++) - const todo = { id, title: title ?? '', completed: Boolean(completed) } - todos.push(todo) - res.status(201).json(todo) - } catch (err) { - res.status(500).json({ error: err.message }) - } -}) - -/** PUT /api/todos/:id — update */ -app.put('/api/todos/:id', (req, res) => { - try { - const idx = todos.findIndex((t) => t.id === req.params.id) - if (idx === -1) return res.status(404).json({ error: 'Not found' }) - const { title, completed } = req.body ?? {} - if (title !== undefined) todos[idx].title = title - if (completed !== undefined) todos[idx].completed = Boolean(completed) - res.json(todos[idx]) - } catch (err) { - res.status(500).json({ error: err.message }) - } -}) - -/** DELETE /api/todos/:id — delete */ -app.delete('/api/todos/:id', (req, res) => { - try { - const idx = todos.findIndex((t) => t.id === req.params.id) - if (idx === -1) return res.status(404).json({ error: 'Not found' }) - const removed = todos.splice(idx, 1)[0] - res.json(removed) - } catch (err) { - res.status(500).json({ error: err.message }) - } -}) - /** Build OpenAI client and full prompt from request body. Returns { openai, modelId, fullPrompt } or { error }. */ function buildAgentRequest(body) { const { prompt, context, contextNodes, connection: conn, reasoning } = body ?? {} diff --git a/frontend/src/app/canvas/CanvasPage.tsx b/frontend/src/app/canvas/CanvasPage.tsx index 532901f..2152c98 100644 --- a/frontend/src/app/canvas/CanvasPage.tsx +++ b/frontend/src/app/canvas/CanvasPage.tsx @@ -194,16 +194,6 @@ export function CanvasPage({ projectId }: CanvasPageProps) { graphRef.current.nodes = nodes graphRef.current.edges = edges - const [apiTodosCount, setApiTodosCount] = React.useState(null) - React.useEffect(() => { - fetch('/api/todos') - .then((r) => r.json()) - .then((data: unknown) => { - if (Array.isArray(data)) setApiTodosCount(data.length) - }) - .catch(() => setApiTodosCount(-1)) - }, []) - const pendingChangesRef = useRef[]>([]) const rafRef = useRef(null) const onNodesChange = useCallback( @@ -644,11 +634,6 @@ export function CanvasPage({ projectId }: CanvasPageProps) { canCopy={selectedNodes.length === 1} onFitView={() => flowActionsRef.current?.fitView?.()} /> - {apiTodosCount !== null && ( -
- Backend API: {apiTodosCount >= 0 ? `${apiTodosCount} todos` : 'unavailable'} -
- )}
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 194f0ae..10b5fab 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -8,14 +8,6 @@ export default defineConfig({ server: { proxy: { // Backend API (dev): proxy to avoid CORS - '/api/todos': { - target: 'http://localhost:8080', - changeOrigin: true, - }, - '/api/todos/': { - target: 'http://localhost:8080', - changeOrigin: true, - }, '/health': { target: 'http://localhost:8080', changeOrigin: true,