2024-06-27 01:10:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Slovocast\Controller;
|
|
|
|
|
|
|
|
use Slovocast\Controller\Controller;
|
|
|
|
use Slovocast\Infrastructure\DatabaseConnectionInterface;
|
|
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
|
|
|
|
class HealthCheck extends Controller
|
|
|
|
{
|
|
|
|
public function __construct(
|
|
|
|
protected DatabaseConnectionInterface $connection
|
|
|
|
) { }
|
|
|
|
|
|
|
|
public function handle(): Response
|
|
|
|
{
|
|
|
|
/**
|
2024-06-27 01:17:29 +00:00
|
|
|
* Check if the Database connections are active
|
2024-06-27 01:10:48 +00:00
|
|
|
* @var PdoDatabaseConnection $this->connection
|
|
|
|
*/
|
|
|
|
$stmt = $this->connection->query("SELECT 1");
|
|
|
|
$dbResult = $stmt->fetch();
|
|
|
|
|
|
|
|
return $this->json([
|
|
|
|
'http' => true,
|
|
|
|
'database' => (bool) $dbResult[0]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|