#!/usr/bin/env node const express = require('express'); const { exec } = require('child_process'); const util = require('util'); const execAsync = util.promisify(exec); const app = express(); const PORT = 3006; // Middleware CORS app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization'); next(); }); // Route de test simple app.get('/api', async (req, res) => { try { // Test simple avec docker ps const { stdout } = await execAsync('docker ps --format "{{.Names}}\t{{.Status}}"'); const containers = stdout.trim().split('\n').map(line => { const [name, status] = line.split('\t'); return { name, status: status.includes('Up') ? 'running' : 'stopped' }; }); res.json({ timestamp: new Date().toISOString(), services: containers, external: [ { name: 'Mempool Signet', status: 'running', response_time: '100ms' }, { name: 'Relay Bootstrap', status: 'running', response_time: '50ms' } ] }); } catch (error) { console.error('Erreur API:', error); res.status(500).json({ error: 'Erreur interne du serveur', details: error.message }); } }); app.get('/health', (req, res) => { res.json({ status: 'ok', timestamp: new Date().toISOString() }); }); app.listen(PORT, '0.0.0.0', () => { console.log(`🚀 API Status simple démarrée sur http://0.0.0.0:${PORT}`); }); module.exports = app;