<?php
declare(strict_types=1);
require_once __DIR__ . '/app.php';

$checks = [
    'php' => PHP_VERSION,
    'ffmpeg' => ffmpeg_is_available() ? 'available' : 'missing',
    'database' => 'pending',
    'time' => gmdate('c'),
];
$statusCode = 200;

try {
    app_boot();
    $checks['database'] = 'connected';
} catch (Throwable $e) {
    $checks['database'] = 'error';
    $checks['error'] = $e->getMessage();
    $statusCode = 500;
}

http_response_code($statusCode);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($checks, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
