const express = require('express'); const cors = require('cors'); const app = express(); app.use(cors({ origin: 'http://localhost:4200' })); app.use(express.json()); // ── GET /api/plants ──────────────────────────────────── app.get('/api/plants', (req, res) => { res.json({ success: true, data: [ { id: 'plant-001', name: 'Internorm Traun', location: 'Traun, Oberösterreich', installedCapacityKwp: 220, status: 'online', installedAt: '2021-06-15', inverterCount: 6, moduleCount: 500, }, { id: 'plant-002', name: 'Internorm Lannach', location: 'Lannach, Steiermark', installedCapacityKwp: 250, status: 'online', installedAt: '2022-03-22', inverterCount: 3, moduleCount: 400, }, { id: 'plant-003', name: 'Internorm Sarleinsbach', location: 'Sarleinsbach, Oberösterreich', installedCapacityKwp: 298, status: 'online', installedAt: '2023-09-01', inverterCount: 2, moduleCount: 250, }, ], }); }); // ── GET /api/plants/:id ──────────────────────────────── app.get('/api/plants/:id', (req, res) => { // Einzelne Anlage zurückgeben res.json({ success: true, data: [ { id: req.params.id /* ... */ } ] }); }); // ── GET /api/plants/:id/live ─────────────────────────── app.get('/api/plants/:id/live', (req, res) => { res.json({ success: true, data: { plantId: req.params.id, timestamp: new Date().toISOString(), currentPowerKw: 312.4, // ← echte Daten von deiner API/DB hier todayEnergyKwh: 1248.6, totalEnergyKwh: 587340, co2SavedKg: 293670, gridFeedInKw: 198.1, selfConsumptionKw: 114.3, irradianceWm2: 748, temperatureCelsius: 32, inverters: [], }, }); }); // ── GET /api/plants/:id/history ──────────────────────── app.get('/api/plants/:id/history', (req, res) => { const resolution = req.query.resolution ?? 'day'; // 'hour'|'day'|'month'|'year' res.json({ success: true, data: [ { timestamp: '2026-03-10T00:00:00Z', energyKwh: 250.5, peakPowerKw: 380.0 }, // weitere Einträge... ], }); }); app.listen(3000, () => console.log('PV API Server läuft auf http://localhost:3000'));