slovocast/app/src/Controller/HealthCheck.php

26 lines
549 B
PHP
Raw Normal View History

<?php
namespace Slovocast\Controller;
use Slovocast\Controller\Controller;
2024-06-27 02:15:43 +00:00
use React\Mysql\MysqlClient;
use function React\Async\await;
use Psr\Http\Message\ResponseInterface as Response;
class HealthCheck extends Controller
{
public function __construct(
2024-06-27 02:15:43 +00:00
protected MysqlClient $db
) { }
public function handle(): Response
{
2024-06-27 02:15:43 +00:00
$results = await($this->db->query("SELECT 1"));
return $this->json([
'http' => true,
'database' => (bool) count($results->resultRows),
]);
}
}