Split monolithic index.ts (~1400 lines) into modular structure: - config.ts: Server configuration and constants - db/: Database initialization, migrations, and seeds - routes/: API handlers by domain (themes, canvas, components, etc.) - services/: Terminal WebSocket server - utils/: CORS helpers Entry point now only coordinates initialization.
30 lines
785 B
TypeScript
30 lines
785 B
TypeScript
import { PORT_HTTP, WORKING_DIR } from './config'
|
|
import { initDatabase } from './db'
|
|
import { handleRequest } from './routes'
|
|
import { startTerminalServer } from './services/terminal'
|
|
|
|
// Initialize database
|
|
initDatabase()
|
|
|
|
// Start HTTP API server
|
|
Bun.serve({
|
|
port: PORT_HTTP,
|
|
fetch: handleRequest
|
|
})
|
|
|
|
console.log(`[HTTP] API running at http://localhost:${PORT_HTTP}`)
|
|
|
|
// Start Terminal WebSocket server
|
|
startTerminalServer()
|
|
|
|
// Startup summary
|
|
console.log('')
|
|
console.log('='.repeat(50))
|
|
console.log('Agent UI Server started')
|
|
console.log(` API: http://localhost:${PORT_HTTP}`)
|
|
console.log(` Terminal: ws://localhost:4103`)
|
|
console.log(` Working Dir: ${WORKING_DIR}`)
|
|
console.log('')
|
|
console.log('WebMCP starts separately with Claude Code MCP')
|
|
console.log('='.repeat(50))
|