Enhance self-serve lane functionality with new relay management and configuration updates

This commit is contained in:
Jeppe Bundgaard
2026-06-02 17:27:22 +02:00
parent 6d739cfebc
commit 1b99523366
18 changed files with 133418 additions and 90 deletions
@@ -276,7 +276,7 @@ trait module_config_variable
private static function readDatabaseConfigFromEnvironment(): array
{
$readEnv = static function (string $key, string $default = ''): string {
$value = $_ENV[$key] ?? getenv($key);
$value = $_ENV[$key] ?? $_SERVER[$key] ?? getenv($key);
if ($value === false || $value === null) {
return $default;
}
@@ -284,9 +284,25 @@ trait module_config_variable
return trim((string)$value);
};
$host = $readEnv('CONFIG_DB_HOST');
$user = $readEnv('CONFIG_DB_USER');
$database = $readEnv('CONFIG_DB_DATABASE');
$dbTarget = strtolower(trim($readEnv('CONFIG_DB_TARGET', 'live')));
if ($dbTarget !== 'live' && $dbTarget !== 'debug') {
$dbTarget = 'live';
}
$resolveDbValue = static function (string $key) use ($dbTarget, $readEnv): string {
$liveValue = $readEnv('CONFIG_DB_' . $key);
$debugValue = $readEnv('CONFIG_DB_DEBUG_' . $key);
if ($dbTarget === 'debug' && $debugValue !== '') {
return $debugValue;
}
return $liveValue;
};
$host = $resolveDbValue('HOST');
$user = $resolveDbValue('USER');
$database = $resolveDbValue('DATABASE');
if ($host === '' || $user === '' || $database === '') {
return [];
@@ -295,10 +311,10 @@ trait module_config_variable
return [
'host' => $host,
'user' => $user,
'password' => $readEnv('CONFIG_DB_PASSWORD'),
'password' => $resolveDbValue('PASSWORD'),
'database' => $database,
'port' => (int)($readEnv('CONFIG_DB_PORT', '3306') ?: '3306'),
'ssl_mode' => $readEnv('CONFIG_DB_SSL_MODE', 'DISABLED') ?: 'DISABLED',
'port' => (int)($resolveDbValue('PORT') ?: '3306'),
'ssl_mode' => $resolveDbValue('SSL_MODE') ?: 'DISABLED',
];
}