# Server Routes (API Endpoints) **Generated:** 2026-02-19 **Location:** server/routes/ ## OVERVIEW Express router modules exposing REST API endpoints for the homelab topology. ## ENDPOINTS | File | Route | Method | Purpose | |------|-------|--------|---------| | discover.ts | /api/discover | POST | Run SSH discovery on specified hosts | | config.ts | /api/config | GET/PUT | Get or update configuration | | stats.ts | /api/stats | GET | Retrieve statistics | | files.ts | /api/files | GET | Get file topology | ## ADDING A NEW ENDPOINT 1. Create `server/routes/{name}.ts`: ```typescript import { Router } from 'express'; const router = Router(); router.get('/{name}', (req, res) => { // implementation }); export default router; ``` 2. Import and mount in `server/index.ts`: ```typescript import newRouter from './routes/{name}'; app.use('/api', newRouter); ``` ## CONVENTIONS - All routes prefixed with `/api` (mounted in index.ts) - Return JSON on success: `{ data: ... }` - On error: `{ error: string }` - Use async/await for async operations ## NOTES - discover.ts: Main endpoint - accepts host list, returns topology data - CORS is configured at server/index.ts level, not per-route