1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* GET /api/runtime-config
|
|
* Liefert die aktuelle Plattform-Konfiguration für Module.
|
|
*
|
|
* Modul ruft das beim Start ab und nutzt die Werte (Heartbeat-Intervall,
|
|
* Stuck-Schwellwert, Rate-Limits etc.) statt fixer Werte. Damit kann
|
|
* eine Lehrperson mit Admin-Rolle im Admin-Board live justieren, ohne
|
|
* Modul-Redeploy.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/../bootstrap.php';
|
|
|
|
v2_validate_method('GET');
|
|
v2_auth_require('any');
|
|
|
|
$rows = v2_db_all("
|
|
SELECT config_key, config_value, value_type
|
|
FROM platform_config_v2
|
|
WHERE group_name IN ('telemetry', 'auth', 'general')
|
|
");
|
|
|
|
$config = [];
|
|
foreach ($rows as $r) {
|
|
$key = $r['config_key'];
|
|
$val = $r['config_value'];
|
|
switch ($r['value_type']) {
|
|
case 'int': $val = (int) $val; break;
|
|
case 'float': $val = (float) $val; break;
|
|
case 'bool': $val = $val === '1' || $val === 'true'; break;
|
|
case 'json': $val = json_decode($val, true); break;
|
|
// string bleibt string
|
|
}
|
|
$config[$key] = $val;
|
|
}
|
|
|
|
// Konsumenten-freundliche Aliases (camelCase) für Module
|
|
$response = [
|
|
'heartbeat' => [
|
|
'minIntervalS' => $config['heartbeat_interval_min_s'] ?? 10,
|
|
'maxIntervalS' => $config['heartbeat_interval_max_s'] ?? 30,
|
|
],
|
|
'stuck' => [
|
|
'thresholdS' => $config['stuck_threshold_s'] ?? 90,
|
|
],
|
|
'telemetry' => [
|
|
'rateLimitPerS' => $config['telemetry_rate_limit_per_s'] ?? 1,
|
|
'eventCapPerSession' => $config['telemetry_event_cap_per_session'] ?? 2000,
|
|
'retentionDays' => $config['telemetry_retention_days'] ?? 30,
|
|
],
|
|
'auth' => [
|
|
'tokenTTLs' => $config['token_ttl_s'] ?? 3600,
|
|
'refreshWindowS' => $config['token_refresh_window_s'] ?? 300,
|
|
],
|
|
'_raw' => $config, // alle Werte als Flat-Dict für Debug-Zwecke
|
|
];
|
|
|
|
v2_response_ok($response);
|