Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(api): create service validation and docs

peaklabs-dev7c7c09aa3d0f
diff --git a/app/Http/Controllers/Api/ServicesController.php b/app/Http/Controllers/Api/ServicesController.php
index 6a00818aa3..ec3d036bc0 100644
--- a/app/Http/Controllers/Api/ServicesController.php
+++ b/app/Http/Controllers/Api/ServicesController.php
@@ -105,98 +105,7 @@ class ServicesController extends Controller
type: 'object',
required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'],
properties: [
- 'type' => [
- 'description' => 'The one-click service type',
- 'type' => 'string',
- 'enum' => [
- 'activepieces',
- 'appsmith',
- 'appwrite',
- 'authentik',
- 'babybuddy',
- 'budge',
- 'changedetection',
- 'chatwoot',
- 'classicpress-with-mariadb',
- 'classicpress-with-mysql',
- 'classicpress-without-database',
- 'cloudflared',
- 'code-server',
- 'dashboard',
- 'directus',
- 'directus-with-postgresql',
- 'docker-registry',
- 'docuseal',
- 'docuseal-with-postgres',
- 'dokuwiki',
- 'duplicati',
- 'emby',
- 'embystat',
- 'fider',
- 'filebrowser',
- 'firefly',
- 'formbricks',
- 'ghost',
- 'gitea',
- 'gitea-with-mariadb',
- 'gitea-with-mysql',
- 'gitea-with-postgresql',
- 'glance',
- 'glances',
- 'glitchtip',
- 'grafana',
- 'grafana-with-postgresql',
- 'grocy',
- 'heimdall',
- 'homepage',
- 'jellyfin',
- 'kuzzle',
- 'listmonk',
- 'logto',
- 'mediawiki',
- 'meilisearch',
- 'metabase',
- 'metube',
- 'minio',
- 'moodle',
- 'n8n',
- 'n8n-with-postgresql',
- 'next-image-transformation',
- 'nextcloud',
- 'nocodb',
- 'odoo',
- 'openblocks',
- 'pairdrop',
- 'penpot',
- 'phpmyadmin',
- 'pocketbase',
- 'posthog',
- 'reactive-resume',
- 'rocketchat',
- 'shlink',
- 'slash',
- 'snapdrop',
- 'statusnook',
- 'stirling-pdf',
- 'supabase',
- 'syncthing',
- 'tolgee',
- 'trigger',
- 'trigger-with-external-database',
- 'twenty',
- 'umami',
- 'unleash-with-postgresql',
- 'unleash-without-database',
- 'uptime-kuma',
- 'vaultwarden',
- 'vikunja',
- 'weblate',
- 'whoogle',
- 'wordpress-with-mariadb',
- 'wordpress-with-mysql',
- 'wordpress-without-database',
- ],
- ],
+ 'type' => ['description' => 'The one-click service type (e.g. "actualbudget", "calibre-web", "gitea-with-mysql" ...)', 'type' => 'string'],
'name' => ['type' => 'string', 'maxLength' => 255, 'description' => 'Name of the service.'],
'description' => ['type' => 'string', 'nullable' => true, 'description' => 'Description of the service.'],
'project_uuid' => ['type' => 'string', 'description' => 'Project UUID.'],
@@ -283,6 +192,13 @@ class ServicesController extends Controller
'errors' => $errors,
], 422);
}
+
+ if (filled($request->type) && filled($request->docker_compose_raw)) {
+ return response()->json([
+ 'message' => 'You cannot provide both service type and docker_compose_raw. Use one or the other.',
+ ], 422);
+ }
+
$environmentUuid = $request->environment_uuid;
$environmentName = $request->environment_name;
if (blank($environmentUuid) && blank($environmentName)) {
@@ -524,8 +440,11 @@ class ServicesController extends Controller
'uuid' => $service->uuid,
'domains' => $domains,
])->setStatusCode(201);
- } else {
- return response()->json(['message' => 'No service type or docker_compose_raw provided.'], 400);
+ } elseif (filled($request->type)) {
+ return response()->json([
+ 'message' => 'Invalid service type.',
+ 'valid_service_types' => $serviceKeys,
+ ], 404);
}
}