2024-06-27 01:10:48 +00:00
|
|
|
<?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;
|
2024-06-27 01:10:48 +00:00
|
|
|
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
|
2024-06-27 01:10:48 +00:00
|
|
|
) { }
|
|
|
|
|
|
|
|
public function handle(): Response
|
|
|
|
{
|
2024-06-27 02:15:43 +00:00
|
|
|
$results = await($this->db->query("SELECT 1"));
|
2024-06-27 01:10:48 +00:00
|
|
|
|
|
|
|
return $this->json([
|
|
|
|
'http' => true,
|
2024-06-27 02:15:43 +00:00
|
|
|
'database' => (bool) count($results->resultRows);
|
2024-06-27 01:10:48 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|