Compare commits
1 Commits
ai/issue-2
...
ai/issue-6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4361fdf9f0 |
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Luca Haid
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
61
public/api/health.php
Normal file
61
public/api/health.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Health check endpoint for thetool
|
||||
* Returns database table count for monitoring purposes
|
||||
*/
|
||||
|
||||
// Bootstrap the application
|
||||
if(file_exists("../../config/config.php")) {
|
||||
require("../../config/config.php");
|
||||
} else {
|
||||
header("Content-Type: application/json");
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "Configuration not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Define FronkDB constants if not already defined
|
||||
if(!defined('FRONKDB_SQLDEBUG')) {
|
||||
define('FRONKDB_SQLDEBUG', false);
|
||||
}
|
||||
|
||||
// Load required classes
|
||||
require_once(LIBDIR."autoloader/autoloader.php");
|
||||
require_once(LIBDIR."mvcfronk/mfLog/mfLoghandler.php");
|
||||
require_once(LIBDIR."FronkDB/FronkDB.php");
|
||||
|
||||
// Get database table count
|
||||
$tableCount = 0;
|
||||
$db = null;
|
||||
|
||||
try {
|
||||
$db = new FronkDB(
|
||||
FRONKDB_DBHOST,
|
||||
FRONKDB_DBUSER,
|
||||
FRONKDB_DBPASS,
|
||||
FRONKDB_DBNAME
|
||||
);
|
||||
|
||||
// Query to get table count
|
||||
$result = $db->query("SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = '".FRONKDB_DBNAME."'");
|
||||
|
||||
if($result) {
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
if($row) {
|
||||
$tableCount = (int)$row['count'];
|
||||
}
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
header("Content-Type: application/json");
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "Database error: " . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return JSON response
|
||||
header("Content-Type: application/json");
|
||||
http_response_code(200);
|
||||
echo json_encode([
|
||||
"status" => "ok",
|
||||
"tables" => $tableCount
|
||||
]);
|
||||
Reference in New Issue
Block a user