Add SportPath auth APIs and training content foundation
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/_bootstrap.php';
|
||||
require_once dirname(__DIR__, 3) . '/backend/JwtToken.php';
|
||||
require_once dirname(__DIR__, 3) . '/backend/ApiAuth.php';
|
||||
api_method('GET');
|
||||
|
||||
try {
|
||||
$database = Database::getInstance();
|
||||
$statement = $database->prepare(
|
||||
'SELECT setting_key, setting_value, revision FROM app_settings WHERE is_public = 1 ORDER BY setting_key'
|
||||
);
|
||||
$statement->execute();
|
||||
$result = $statement->get_result();
|
||||
$settings = [];
|
||||
$revision = 0;
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$decoded = json_decode($row['setting_value'], true);
|
||||
$settings[$row['setting_key']] = $decoded;
|
||||
$revision = max($revision, (int) $row['revision']);
|
||||
}
|
||||
|
||||
header('Cache-Control: public, max-age=60, stale-while-revalidate=300');
|
||||
api_json(['revision' => $revision, 'settings' => $settings]);
|
||||
} catch (Throwable $exception) {
|
||||
error_log('Public configuration unavailable: ' . $exception->getMessage());
|
||||
api_json(['error' => 'service_unavailable'], 503);
|
||||
}
|
||||
Reference in New Issue
Block a user