27 lines
836 B
PHP
27 lines
836 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/lending_app.php';
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
try {
|
|
lending_ensure_schema();
|
|
$statement = db()->query('SELECT 1 AS healthy');
|
|
$healthy = (int) ($statement ? $statement->fetchColumn() : 0) === 1;
|
|
|
|
http_response_code($healthy ? 200 : 500);
|
|
echo json_encode([
|
|
'status' => $healthy ? 'ok' : 'error',
|
|
'database' => $healthy ? 'ok' : 'error',
|
|
'checked_at' => gmdate('c'),
|
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
|
} catch (Throwable $exception) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'status' => 'error',
|
|
'database' => 'error',
|
|
'checked_at' => gmdate('c'),
|
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
|
}
|