Implement Backend API, MCP Server, and Gitea integration
All checks were successful
Build and Push Backend / build (push) Successful in 5s

- Add REST API routes for projects, tasks, and agents (CRUD operations)
- Implement MCP Server with 4 core tools:
  - get_next_task: Assign tasks to agents
  - update_task_status: Update task states
  - create_branch: Create Git branches via Gitea API
  - create_pull_request: Create PRs via Gitea API
- Add Gitea API client for repository operations
- Fix database migration error handling for existing tables
- Connect all routes to Bun.serve() main server

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hector Ros
2026-01-20 00:43:46 +01:00
parent ebf5d74933
commit 5672127593
12 changed files with 1631 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
import { runMigrations } from './db/migrate'
import { testConnection } from './db/client'
import { handleProjectRoutes, handleTaskRoutes, handleAgentRoutes } from './api/routes'
console.log('🚀 Starting AiWorker Backend...')
console.log(`Bun version: ${Bun.version}`)
@@ -41,11 +42,43 @@ const server = Bun.serve({
}
// API routes
if (url.pathname.startsWith('/api/projects')) {
return handleProjectRoutes(req, url)
}
if (url.pathname.startsWith('/api/tasks')) {
return handleTaskRoutes(req, url)
}
if (url.pathname.startsWith('/api/agents')) {
return handleAgentRoutes(req, url)
}
// Generic API info
if (url.pathname.startsWith('/api/')) {
return Response.json({
message: 'AiWorker API',
path: url.pathname,
method: req.method,
version: '1.0.0',
endpoints: [
'GET /api/health',
'GET /api/projects',
'GET /api/projects/:id',
'POST /api/projects',
'PATCH /api/projects/:id',
'DELETE /api/projects/:id',
'GET /api/tasks',
'GET /api/tasks/:id',
'POST /api/tasks',
'PATCH /api/tasks/:id',
'POST /api/tasks/:id/respond',
'DELETE /api/tasks/:id',
'GET /api/agents',
'GET /api/agents/:id',
'POST /api/agents',
'PATCH /api/agents/:id',
'POST /api/agents/:id/heartbeat',
'DELETE /api/agents/:id',
],
})
}