feat: implement issue #6

Resolves luca/thetool#6
Closes #6
This commit is contained in:
AI Development Engine
2026-03-02 10:26:54 +00:00
parent 7010e15f16
commit d02e4311dd

36
public/api/health.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
// Health check endpoint - returns number of tables in thetool database
// Define required constants before loading config
define('FRONKDB_SQLDEBUG', false);
// Load the framework's database configuration
require_once(__DIR__ . "/../../config/config.php");
// Load the autoloader to get FronkDB class
require_once(__DIR__ . "/../../lib/autoloader/autoloader.php");
require_once(__DIR__ . "/../../lib/mvcfronk/mfLog/mfLoghandler.php");
require_once(__DIR__ . "/../../lib/FronkDB/FronkDB.php");
// Connect to the database using the framework's configuration
$db = new FronkDB(
FRONKDB_DBHOST,
FRONKDB_DBUSER,
FRONKDB_DBPASS,
FRONKDB_DBNAME
);
// Query to count tables in the thetool database
$sql = "SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = 'thetool'";
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_array($result);
$tableCount = (int)$row['count'];
} else {
$tableCount = 0;
}
// Return JSON response
header('Content-Type: application/json');
echo json_encode(['tables' => $tableCount]);