UNPKG

orchestry-mcp

Version:

Orchestry MCP Server for multi-session task management

157 lines 5.13 kB
import express from 'express'; export function setupAPI(app, db, io) { // Health check app.get('/api/health', (req, res) => { res.json({ status: 'ok', timestamp: new Date() }); }); // Projects app.get('/api/projects', (req, res) => { try { const projects = db.getAllProjects(); res.json(projects); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); app.get('/api/projects/:id', (req, res) => { try { const project = db.getProject(req.params.id); if (!project) { return res.status(404).json({ error: 'Project not found' }); } res.json(project); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); app.post('/api/projects', (req, res) => { try { const { name, description, sessionId } = req.body; console.log('Creating project:', { name, description, sessionId }); const project = db.createProject(name, description, sessionId); io.emit('project_created', project); res.json(project); } catch (error) { console.error('Error creating project:', error); res.status(500).json({ error: 'Internal server error', details: error instanceof Error ? error.message : 'Unknown error' }); } }); // Workspaces app.post('/api/workspaces', (req, res) => { try { const workspace = db.createWorkspace(req.body.projectId, req.body); io.emit('workspace_created', workspace); res.json(workspace); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Goals app.post('/api/goals', (req, res) => { try { const goal = db.createGoal(req.body.workspaceId, req.body); io.emit('goal_created', goal); res.json(goal); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Tasks app.post('/api/tasks', (req, res) => { try { const task = db.createTask(req.body.goalId, req.body); io.emit('task_created', task); res.json(task); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); app.get('/api/tasks/:id', (req, res) => { try { const task = db.getTask(req.params.id); if (!task) { return res.status(404).json({ error: 'Task not found' }); } res.json(task); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); app.put('/api/tasks/:id/status', (req, res) => { try { db.updateTaskStatus(req.params.id, req.body.status); const task = db.getTask(req.params.id); io.emit('task_updated', task); res.json(task); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Sessions app.post('/api/sessions', (req, res) => { try { const session = db.createSession(req.body.projectId, req.body); io.emit('session_created', session); res.json(session); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); app.get('/api/projects/:id/sessions', (req, res) => { try { const sessions = db.getActiveSessions(req.params.id); res.json(sessions); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Kanban Board app.get('/api/projects/:id/board', (req, res) => { try { const board = db.getKanbanBoard(req.params.id); res.json(board); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Project Stats app.get('/api/projects/:id/stats', (req, res) => { try { const stats = db.getProjectStats(req.params.id); res.json(stats); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Project Hierarchy app.get('/api/projects/:id/hierarchy', (req, res) => { try { const project = db.getProject(req.params.id); const stats = db.getProjectStats(req.params.id); res.json({ project, stats }); } catch (error) { res.status(500).json({ error: 'Internal server error' }); } }); // Static files for web UI (production only) if (process.env.NODE_ENV === 'production') { app.use('/', express.static('../web/dist')); } } //# sourceMappingURL=index.js.map