/** * Demo-Modul: Minimaler HTTP-Server, der den Modul-API-Vertrag erfüllt. * Läuft als eigener Node-Prozess im Management-Container (Port via ENV PORT). */ const http = require('node:http'); const PORT = Number(process.env.PORT ?? 41001); /** Manifest des Moduls (identisch zu module.json). */ const MANIFEST = { moduleId: 'demo', version: '1.0.0', status: 'healthy', }; const server = http.createServer((request, response) => { const url = new URL(request.url ?? '/', `http://127.0.0.1:${PORT}`); if (url.pathname === '/health') { response.writeHead(200, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ moduleId: 'demo', version: '1.0.0', status: 'healthy' })); return; } if (url.pathname === '/api/manifest') { response.writeHead(200, { 'Content-Type': 'application/json' }); response.end(JSON.stringify(MANIFEST)); return; } if (url.pathname === '/api/me') { response.writeHead(200, { 'Content-Type': 'application/json' }); response.end( JSON.stringify({ user: { id: 'demo', username: 'demo' }, module: { id: 'demo' }, permissions: [], }), ); return; } response.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' }); response.end('Demo-Modul läuft'); }); server.listen(PORT, '127.0.0.1', () => { console.log(`Demo-Modul läuft auf Port ${PORT}`); });