Skip to content

Commit e3a28b9

Browse files
committed
add health endpoint
1 parent 6dbb83f commit e3a28b9

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\JsonResponse;
6+
use Illuminate\Support\Facades\DB;
7+
8+
class HealthController extends Controller
9+
{
10+
public function __invoke(): JsonResponse
11+
{
12+
try {
13+
DB::connection()->getPdo();
14+
$dbStatus = 'ok';
15+
} catch (\Exception $e) {
16+
$dbStatus = 'error';
17+
}
18+
19+
$status = $dbStatus === 'ok' ? 'healthy' : 'unhealthy';
20+
$httpCode = $status === 'healthy' ? 200 : 503;
21+
22+
return response()->json([
23+
'status' => $status,
24+
'timestamp' => now()->toISOString(),
25+
'services' => [
26+
'database' => $dbStatus,
27+
],
28+
], $httpCode);
29+
}
30+
}

infra/dev/image/Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ WORKDIR /var/www/html
1414
# PHP version to be installed
1515
# See: https://rpms.remirepo.net/wizard/
1616
# WARNING: PHP 8.2 have only security only support until December 2026
17-
ARG PHP_VERSION=8.2
17+
ARG PHP_VERSION=8.3
1818

1919
# list of all PHP packages to be installed
2020
ARG PHP_PACKAGES="php-cli composer php-intl php-json php-mbstring php-mysqlnd php-opcache php-pdo php-gd php-redis php-xml php-swoole php-zip php-sodium php-bcmath"

routes/api.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use App\Http\Controllers\Api\v1\GroupUserController;
55
use App\Http\Controllers\Api\v1\IntrospectionController;
66
use App\Http\Controllers\Api\v1\UserinfoController;
7+
use App\Http\Controllers\HealthController;
78
use Illuminate\Support\Facades\Route;
89

910
/*
@@ -34,3 +35,6 @@
3435
// Introspect requires auth via client id + secret
3536
Route::post('introspect', IntrospectionController::class)->name('introspect');
3637
});
38+
39+
// Health check endpoint - no authentication required
40+
Route::get('health', HealthController::class)->name('health');

0 commit comments

Comments
 (0)