From c8b9abf559e9559d77f2a784e08af8610d0fe533 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Wed, 26 Jun 2024 22:15:43 -0400 Subject: [PATCH] Update the healthcheck --- app/src/Controller/HealthCheck.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/Controller/HealthCheck.php b/app/src/Controller/HealthCheck.php index 7a66692..46c03f4 100644 --- a/app/src/Controller/HealthCheck.php +++ b/app/src/Controller/HealthCheck.php @@ -3,27 +3,23 @@ namespace Slovocast\Controller; use Slovocast\Controller\Controller; -use Slovocast\Infrastructure\DatabaseConnectionInterface; +use React\Mysql\MysqlClient; +use function React\Async\await; use Psr\Http\Message\ResponseInterface as Response; class HealthCheck extends Controller { public function __construct( - protected DatabaseConnectionInterface $connection + protected MysqlClient $db ) { } public function handle(): Response { - /** - * Check if the Database connections are active - * @var PdoDatabaseConnection $this->connection - */ - $stmt = $this->connection->query("SELECT 1"); - $dbResult = $stmt->fetch(); + $results = await($this->db->query("SELECT 1")); return $this->json([ 'http' => true, - 'database' => (bool) $dbResult[0] + 'database' => (bool) count($results->resultRows); ]); } }