Refactor: Centralize service application prerequisites

Refactors the Appwrite and Beszel service-specific application settings
to use a centralized constant-based approach, following the same pattern
as NEEDS_TO_CONNECT_TO_PREDEFINED_NETWORK.

Changes:
- Added NEEDS_TO_DISABLE_GZIP constant for services requiring gzip disabled
- Added NEEDS_TO_DISABLE_STRIPPREFIX constant for services requiring stripprefix disabled
- Created applyServiceApplicationPrerequisites() helper function in bootstrap/helpers/services.php
- Updated all service creation flows to use the centralized helper:
  * app/Livewire/Project/Resource/Create.php (web handler)
  * app/Http/Controllers/Api/ServicesController.php (API handler - BUG FIX)
  * app/Livewire/Project/New/DockerCompose.php (custom compose handler)
  * app/Http/Controllers/Api/ApplicationsController.php (API custom compose handler)
- Added comprehensive unit tests for the new helper function

Benefits:
- Single source of truth for service prerequisites
- DRY - eliminates code duplication between web and API handlers
- Fixes bug where API-created services didn't get prerequisites applied
- Easy to extend for future services (just edit the constant)
- More maintainable and testable

Related commits: 3a94f1ea1 (Beszel), 02b18c86e (Appwrite)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-11-28 16:33:27 +01:00
parent b246cdffab
commit 4706bc23aa
7 changed files with 174 additions and 19 deletions

View File

@@ -104,25 +104,8 @@ class Create extends Component
}
$service->parse(isNew: true);
// For Beszel service disable gzip (fixes realtime not working issue)
if ($oneClickServiceName === 'beszel') {
$appService = $service->applications()->whereName('beszel')->first();
if ($appService) {
$appService->is_gzip_enabled = false;
$appService->save();
}
}
// For Appwrite services, disable strip prefix for services that handle domain requests
if ($oneClickServiceName === 'appwrite') {
$servicesToDisableStripPrefix = ['appwrite', 'appwrite-console', 'appwrite-realtime'];
foreach ($servicesToDisableStripPrefix as $serviceName) {
$appService = $service->applications()->whereName($serviceName)->first();
if ($appService) {
$appService->is_stripprefix_enabled = false;
$appService->save();
}
}
}
// Apply service-specific application prerequisites
applyServiceApplicationPrerequisites($service);
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,