Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SystemHealthController | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| show | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers\v2\Admin\SystemDashboard; |
| 4 | |
| 5 | use App\Http\Controllers\Controller; |
| 6 | use App\Http\Requests\v2\Admin\SystemDashboard\SystemHealthRequest; |
| 7 | use App\Http\Resources\v2\Admin\SystemDashboard\SystemHealthResource; |
| 8 | use App\Http\Services\Admin\SystemDashboard\SystemHealthService; |
| 9 | use Illuminate\Http\JsonResponse; |
| 10 | |
| 11 | /** |
| 12 | * Admin-only system health endpoint. |
| 13 | * |
| 14 | * Always returns HTTP 200 — the UI surfaces per-component status. |
| 15 | * The public /api/v1/health endpoint is unchanged and keeps 200/207 semantics. |
| 16 | * |
| 17 | * Masquerade note: authorization is enforced via AuthorizesVengresoAdmin in the |
| 18 | * FormRequest. Masqueraded sessions use the target user's token which does not |
| 19 | * carry the VENGRESO_ADMIN role, so they are rejected at the FormRequest layer. |
| 20 | */ |
| 21 | class SystemHealthController extends Controller |
| 22 | { |
| 23 | public function __construct( |
| 24 | private SystemHealthService $service |
| 25 | ) {} |
| 26 | |
| 27 | /** |
| 28 | * GET /api/v2/admin/system/health |
| 29 | * |
| 30 | * @response 200 {"result": {"checked_at": 1715000000, "statuses": {...}}} |
| 31 | */ |
| 32 | public function show(SystemHealthRequest $request): JsonResponse |
| 33 | { |
| 34 | $statuses = $this->service->collect(); |
| 35 | $resource = new SystemHealthResource($statuses); |
| 36 | |
| 37 | return response()->json($resource->toArray($request)); |
| 38 | } |
| 39 | } |