ad server
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
# Node
|
# Node
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/server/node_modules
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
|
||||||
|
|||||||
1231
server/package-lock.json
generated
Normal file
1231
server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
server/package.json
Normal file
16
server/package.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "pv-pulse-server",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node server.js",
|
||||||
|
"dev": "nodemon server.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"express": "^4.18.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^3.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
90
server/server.js
Normal file
90
server/server.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
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'));
|
||||||
Reference in New Issue
Block a user