Files
idea.llm.gitea.repo.docker.…/api/server.js
Clint Masden feec35ffce Add full REST API for all deployment operations (projects, servers, docker)
Port all IPC handlers to HTTP endpoints so the UI and LLM use the same
API. Adds routes/projects.js (scan, compare, init), routes/servers.js
(CRUD, containers, logs), routes/docker.js (build, deploy, pull, vscode-diff).
Enhanced ssh.js with full SSHService class (SFTP upload/download).
Updated renderer api.js to use fetch instead of window.api IPC.
Added concurrently for npm run dev (API + Vite + Electron).
OpenAPI spec now covers all 24 endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 11:17:40 -06:00

40 lines
1.3 KiB
JavaScript

import express from 'express';
import cors from 'cors';
import { apiReference } from '@scalar/express-api-reference';
import { readFileSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import coolifyRoutes from './routes/coolify.js';
import projectRoutes from './routes/projects.js';
import serverRoutes from './routes/servers.js';
import dockerRoutes from './routes/docker.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const spec = JSON.parse(readFileSync(join(__dirname, 'openapi.json'), 'utf8'));
const app = express();
const PORT = process.env.PORT || 3100;
app.use(cors());
app.use(express.json({ limit: '50mb' }));
// API routes
app.use('/api/coolify', coolifyRoutes);
app.use('/api/projects', projectRoutes);
app.use('/api/servers', serverRoutes);
app.use('/api/docker', dockerRoutes);
// OpenAPI spec
app.get('/openapi.json', (req, res) => res.json(spec));
// Scalar API docs
app.use('/reference', apiReference({ spec: { url: '/openapi.json' } }));
// Health check
app.get('/api/health', (req, res) => res.json({ status: 'ok', timestamp: new Date().toISOString() }));
app.listen(PORT, () => {
console.log(`API server running on http://localhost:${PORT}`);
console.log(`Scalar docs at http://localhost:${PORT}/reference`);
});