36
public/api/health.php
Normal file
36
public/api/health.php
Normal 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]);
|
||||
Reference in New Issue
Block a user