From 9295a4e7ce838051081b11395031e15cae20605d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 25 Oct 2024 19:25:51 +0200 Subject: [PATCH 01/14] Update depenrencies --- app/views/install/compose.phtml | 2 +- composer.lock | 14 +++++++------- docker-compose.yml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index ad35135a6f..32d240242a 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -795,7 +795,7 @@ $image = $this->getParam('image', ''); <<: *x-logging restart: unless-stopped stop_signal: SIGINT - image: openruntimes/executor:0.6.11 + image: openruntimes/executor:0.6.21 networks: - appwrite - runtimes diff --git a/composer.lock b/composer.lock index a7e95a95ca..7c9019197b 100644 --- a/composer.lock +++ b/composer.lock @@ -157,16 +157,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.16.2", + "version": "0.16.3", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "c33005e3eaaf2d427e9fd1077d5335e31f4d36f9" + "reference": "a8458e1d1e29782160f7301479e202f703373419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/c33005e3eaaf2d427e9fd1077d5335e31f4d36f9", - "reference": "c33005e3eaaf2d427e9fd1077d5335e31f4d36f9", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/a8458e1d1e29782160f7301479e202f703373419", + "reference": "a8458e1d1e29782160f7301479e202f703373419", "shasum": "" }, "require": { @@ -206,9 +206,9 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.16.2" + "source": "https://github.com/appwrite/runtimes/tree/0.16.3" }, - "time": "2024-10-09T15:02:52+00:00" + "time": "2024-10-25T16:04:32+00:00" }, { "name": "beberlei/assert", @@ -7029,5 +7029,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/docker-compose.yml b/docker-compose.yml index 91f39ff944..f823a38684 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -880,7 +880,7 @@ services: hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.6.11 + image: openruntimes/executor:0.6.21 restart: unless-stopped networks: - appwrite From e4dd9bc9f98310e53982ce5ea17b0a35238ff363 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sat, 26 Oct 2024 17:07:15 +0200 Subject: [PATCH 02/14] Use custom domain in create site endpoint --- .../Platform/Modules/Sites/Http/Sites/CreateSite.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index c8e30a5ab9..bf4ac62aeb 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -64,6 +64,7 @@ class CreateSite extends Base ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('fallbackRedirect', '', new Text(8192, 0), 'Fallback Redirect URL for site in case a route is not found.', true) + ->param('subDomain', '', new CustomId(), 'Unique custom sub-domain. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) //TODO: Update description of scopes ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) @@ -92,7 +93,7 @@ class CreateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $subDomain, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) { $siteId = ($siteId == 'unique()') ? ID::unique() : $siteId; @@ -215,7 +216,7 @@ class CreateSite extends Base $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); if (!empty($sitesDomain)) { $ruleId = ID::unique(); - $routeSubdomain = ID::unique(); + $routeSubdomain = $subDomain ?? ID::unique(); $domain = "{$routeSubdomain}.{$sitesDomain}"; $rule = Authorization::skip( From 6ac81dea19a383be291800cb6412f1dca593d86b Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sat, 26 Oct 2024 18:34:58 +0200 Subject: [PATCH 03/14] Check if subdomain exists before creating site --- composer.lock | 12 ++++----- .../Modules/Sites/Http/Sites/CreateSite.php | 25 +++++++++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/composer.lock b/composer.lock index a7e95a95ca..91e9210fd8 100644 --- a/composer.lock +++ b/composer.lock @@ -157,16 +157,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.16.2", + "version": "0.16.4", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "c33005e3eaaf2d427e9fd1077d5335e31f4d36f9" + "reference": "7e4741337b9373f77210396e68eca539018cabd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/c33005e3eaaf2d427e9fd1077d5335e31f4d36f9", - "reference": "c33005e3eaaf2d427e9fd1077d5335e31f4d36f9", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/7e4741337b9373f77210396e68eca539018cabd1", + "reference": "7e4741337b9373f77210396e68eca539018cabd1", "shasum": "" }, "require": { @@ -206,9 +206,9 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.16.2" + "source": "https://github.com/appwrite/runtimes/tree/0.16.4" }, - "time": "2024-10-09T15:02:52+00:00" + "time": "2024-10-26T10:39:59+00:00" }, { "name": "beberlei/assert", diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index bf4ac62aeb..18daaeae53 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -18,6 +18,7 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; +use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; @@ -95,6 +96,25 @@ class CreateSite extends Base public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $subDomain, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) { + $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); + $ruleId = ''; + $routeSubdomain = ''; + $domain = ''; + + if (!empty($sitesDomain)) { + $ruleId = ID::unique(); + $routeSubdomain = $subDomain ?? ID::unique(); + $domain = "{$routeSubdomain}.{$sitesDomain}"; + + $subDomain = Authorization::skip(fn () => $dbForConsole->findOne('rules', [ + Query::equal('domain', [$domain]) + ])); + + if (!empty($subDomain)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Subdomain already exists. Please choose a different subdomain.'); + } + } + $siteId = ($siteId == 'unique()') ? ID::unique() : $siteId; $allowList = \array_filter(\explode(',', System::getEnv('_APP_SITES_FRAMEWORKS', ''))); @@ -213,12 +233,7 @@ class CreateSite extends Base ->setTemplate($template); } - $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); if (!empty($sitesDomain)) { - $ruleId = ID::unique(); - $routeSubdomain = $subDomain ?? ID::unique(); - $domain = "{$routeSubdomain}.{$sitesDomain}"; - $rule = Authorization::skip( fn () => $dbForConsole->createDocument('rules', new Document([ '$id' => $ruleId, From ea6765c68a7ea7946ab933f19327986a0b547521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 26 Oct 2024 18:43:30 +0200 Subject: [PATCH 04/14] Support static sites --- .env | 3 +- app/config/collections.php | 35 ++++++--- app/config/frameworks.php | 74 +++++++++++++++---- app/controllers/general.php | 20 ++--- app/views/install/compose.phtml | 2 +- composer.lock | 12 +-- docker-compose.yml | 5 +- .../Modules/Functions/Workers/Builds.php | 7 +- .../Modules/Sites/Http/Sites/CreateSite.php | 8 +- src/Appwrite/Utopia/Response/Model/Func.php | 2 +- src/Appwrite/Utopia/Response/Model/Site.php | 19 +++-- src/Executor/Executor.php | 2 + 12 files changed, 126 insertions(+), 63 deletions(-) diff --git a/.env b/.env index a663c0d278..6ec7e9fba1 100644 --- a/.env +++ b/.env @@ -79,7 +79,8 @@ _APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://proxy/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 -_APP_SITES_FRAMEWORKS=sveltekit,nextjs +_APP_SITES_RUNTIMES=static-1,node-22 +_APP_SITES_FRAMEWORKS=sveltekit,nextjs,static _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 diff --git a/app/config/collections.php b/app/config/collections.php index 8847c8279a..4c9b28ba01 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3402,17 +3402,6 @@ $projectCollections = array_merge([ 'default' => APP_FUNCTION_SPECIFICATION_DEFAULT, 'filters' => [], ], - [ - '$id' => ID::custom('scopes'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], [ '$id' => ID::custom('fallbackRedirect'), 'type' => Database::VAR_STRING, @@ -3423,7 +3412,29 @@ $projectCollections = array_merge([ 'default' => null, 'array' => false, 'filters' => [], - ] + ], + [ + '$id' => ID::custom('serveRuntime'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => true, + 'default' => '', + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('buildRuntime'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => true, + 'default' => '', + 'array' => false, + 'filters' => [], + ], ], 'indexes' => [ [ diff --git a/app/config/frameworks.php b/app/config/frameworks.php index e8bf58286d..c553636d48 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -4,27 +4,75 @@ * List of Appwrite Sites supported frameworks */ + const TEMPLATE_RUNTIMES = [ + 'NODE' => [ + 'name' => 'node', + 'versions' => ['22', '21.0', '20.0', '19.0', '18.0', '16.0', '14.5'] + ], + 'PYTHON' => [ + 'name' => 'python', + 'versions' => ['3.12', '3.11', '3.10', '3.9', '3.8'] + ], + 'DART' => [ + 'name' => 'dart', + 'versions' => ['3.5', '3.3', '3.1', '3.0', '2.19', '2.18', '2.17', '2.16', '2.16'] + ], + 'GO' => [ + 'name' => 'go', + 'versions' => ['1.23'] + ], + 'PHP' => [ + 'name' => 'php', + 'versions' => ['8.3', '8.2', '8.1', '8.0'] + ], + 'DENO' => [ + 'name' => 'deno', + 'versions' => ['2.0', '1.46', '1.40', '1.35', '1.24', '1.21'] + ], + 'BUN' => [ + 'name' => 'bun', + 'versions' => ['1.1', '1.0'] + ], + 'RUBY' => [ + 'name' => 'ruby', + 'versions' => ['3.3', '3.2', '3.1', '3.0'] + ], +]; + + function getVersions(array $versions, string $prefix) { + return array_map(function ($version) use ($prefix) { + return $prefix . '-' . $version; + }, $versions); + } + return [ - "sveltekit" => [ + 'sveltekit' => [ 'key' => 'sveltekit', 'name' => 'SvelteKit', 'logo' => 'sveltekit.png', - 'defaultRuntime' => 'node-20.0', - 'runtimes' => [ - 'node-16.0', - 'node-18.0', - 'node-20.0' - ], + 'defaultServeRuntime' => 'node-22', + 'serveRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node'), + 'defaultBuildRuntime' => 'node-22', + 'buildRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node') ], - "nextjs" => [ + 'nextjs' => [ 'key' => 'nextjs', 'name' => 'Next.js', 'logo' => 'nextjs.png', - 'defaultRuntime' => 'node-20.0', - 'runtimes' => [ - 'node-16.0', - 'node-18.0', - 'node-20.0' + 'defaultServeRuntime' => 'node-22', + 'serveRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node'), + 'defaultBuildRuntime' => 'node-22', + 'buildRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node') + ], + 'static' => [ + 'key' => 'static', + 'name' => 'Static', + 'logo' => 'static.png', + 'defaultServeRuntime' => 'static-1', + 'serveRuntimes' => [ + 'static-1' ], + 'defaultBuildRuntime' => 'node-22', + 'buildRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node') ] ]; diff --git a/app/controllers/general.php b/app/controllers/general.php index 378cfbfd84..08f41203d9 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -142,23 +142,17 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo throw new AppwriteException(AppwriteException::FUNCTION_NOT_FOUND); } - $version = $resource->getAttribute('version', 'v2'); + $version = match($type) { + 'function' => $resource->getAttribute('version', 'v2'), + 'site' => 'v4' + }; + $runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []); $spec = Config::getParam('runtime-specifications')[$resource->getAttribute('specification', APP_FUNCTION_SPECIFICATION_DEFAULT)]; - //todo: have runtime configs for sites $runtime = match($type) { - 'function' => (isset($runtimes[$resource->getAttribute('runtime', '')])) ? $runtimes[$resource->getAttribute('runtime', '')] : null, - 'site' => [ - 'key' => 'static-for-now', - 'name' => 'Static', - 'logo' => 'node.png', - 'startCommand' => null, - 'version' => 'v1', - 'base' => 'static:1.0', - 'image' => 'static:1.0', - 'supports' => [System::X86, System::ARM64, System::ARMV7, System::ARMV8] - ], + 'function' => $runtimes[$resource->getAttribute('runtime')] ?? null, + 'site' => $runtimes[$resource->getAttribute('serveRuntime')] ?? null, default => null }; diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 32d240242a..27180750b6 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -795,7 +795,7 @@ $image = $this->getParam('image', ''); <<: *x-logging restart: unless-stopped stop_signal: SIGINT - image: openruntimes/executor:0.6.21 + image: openruntimes/executor:0.6.24 networks: - appwrite - runtimes diff --git a/composer.lock b/composer.lock index 7c9019197b..7fddad201f 100644 --- a/composer.lock +++ b/composer.lock @@ -157,16 +157,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.16.3", + "version": "0.16.4", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "a8458e1d1e29782160f7301479e202f703373419" + "reference": "7e4741337b9373f77210396e68eca539018cabd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/a8458e1d1e29782160f7301479e202f703373419", - "reference": "a8458e1d1e29782160f7301479e202f703373419", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/7e4741337b9373f77210396e68eca539018cabd1", + "reference": "7e4741337b9373f77210396e68eca539018cabd1", "shasum": "" }, "require": { @@ -206,9 +206,9 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.16.3" + "source": "https://github.com/appwrite/runtimes/tree/0.16.4" }, - "time": "2024-10-25T16:04:32+00:00" + "time": "2024-10-26T10:39:59+00:00" }, { "name": "beberlei/assert", diff --git a/docker-compose.yml b/docker-compose.yml index f823a38684..dc58d0c3c0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -162,6 +162,7 @@ services: - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY - _APP_FUNCTIONS_RUNTIMES + - _APP_SITES_RUNTIMES - _APP_SITES_FRAMEWORKS - _APP_SITES_CPUS - _APP_SITES_MEMORY @@ -880,7 +881,7 @@ services: hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.6.21 + image: openruntimes/executor:0.6.24 restart: unless-stopped networks: - appwrite @@ -899,7 +900,7 @@ services: - OPR_EXECUTOR_DOCKER_HUB_USERNAME=$_APP_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD=$_APP_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV - - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES + - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES,$_APP_SITES_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v4 - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 4baca4f1bd..43d2c51240 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -570,7 +570,8 @@ class Builds extends Action entrypoint: $deployment->getAttribute('entrypoint', 'package.json'), // TODO: change this later so that sites don't need to have an entrypoint destination: APP_STORAGE_BUILDS . "/app-{$project->getId()}", variables: $vars, - command: $command + command: $command, + outputDirectory: $resource->getAttribute('outputDirectory', '') ); } catch (\Throwable $error) { $err = $error; @@ -808,8 +809,8 @@ class Builds extends Action $runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []); $key = $resource->getAttribute('runtime'); $runtime = match ($resource->getCollection()) { - 'functions' => $runtimes[$key] ?? null, - 'sites' => $runtimes['node-18.0'] ?? null, //todo: fix hardcode + 'functions' => $runtimes[$resource->getAttribute('runtime')] ?? null, + 'sites' => $runtimes[$resource->getAttribute('buildRuntime')] ?? null, default => null }; if (\is_null($runtime)) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index c8e30a5ab9..6c62f02fe6 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -64,7 +64,6 @@ class CreateSite extends Base ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('fallbackRedirect', '', new Text(8192, 0), 'Fallback Redirect URL for site in case a route is not found.', true) - ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) //TODO: Update description of scopes ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) ->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the site.', true) @@ -92,7 +91,7 @@ class CreateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) { $siteId = ($siteId == 'unique()') ? ID::unique() : $siteId; @@ -138,7 +137,6 @@ class CreateSite extends Base 'buildCommand' => $buildCommand, 'outputDirectory' => $outputDirectory, 'fallbackRedirect' => $fallbackRedirect, - 'scopes' => $scopes, 'search' => implode(' ', [$siteId, $name, $framework]), 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getInternalId(), @@ -148,7 +146,9 @@ class CreateSite extends Base 'providerBranch' => $providerBranch, 'providerRootDirectory' => $providerRootDirectory, 'providerSilentMode' => $providerSilentMode, - 'specification' => $specification + 'specification' => $specification, + 'buildRuntime' => Config::getParam('frameworks', [])[$framework]['defaultBuildRuntime'], + 'serveRuntime' => Config::getParam('frameworks', [])[$framework]['defaultServeRuntime'], ])); // Git connect logic diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index f4ff214d0b..3670d4272d 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -61,7 +61,7 @@ class Func extends Model ]) ->addRule('runtime', [ 'type' => self::TYPE_STRING, - 'description' => 'Function execution runtime.', + 'description' => 'Function execution and build runtime.', 'default' => '', 'example' => 'python-3.8', ]) diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index 7c4a9a265d..f4c16b1219 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -58,13 +58,6 @@ class Site extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) - ->addRule('scopes', [ - 'type' => self::TYPE_STRING, - 'description' => 'Allowed permission scopes.', - 'default' => [], - 'example' => 'users.read', - 'array' => true, - ]) ->addRule('vars', [ 'type' => Response::MODEL_VARIABLE, 'description' => 'Site variables.', @@ -132,6 +125,18 @@ class Site extends Model 'default' => APP_SITE_SPECIFICATION_DEFAULT, 'example' => APP_SITE_SPECIFICATION_DEFAULT, ]) + ->addRule('buildRuntime', [ + 'type' => self::TYPE_STRING, + 'description' => 'Site build runtime.', + 'default' => '', + 'example' => 'node-22', + ]) + ->addRule('serveRuntime', [ + 'type' => self::TYPE_STRING, + 'description' => 'Site serve runtime.', + 'default' => '', + 'example' => 'static-1', + ]) ; } diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index c230cfb664..37b3aafbda 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -67,6 +67,7 @@ class Executor string $destination = '', array $variables = [], string $command = null, + string $outputDirectory = '' ) { $runtimeId = "$projectId-$deploymentId-build"; $route = "/runtimes"; @@ -90,6 +91,7 @@ class Executor 'memory' => $memory, 'version' => $version, 'timeout' => $timeout, + 'outputDirectory' => $outputDirectory ]; $response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout); From 93222bf3f9c36b422e89d038cb55a336eee4b477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 26 Oct 2024 20:47:43 +0200 Subject: [PATCH 05/14] Fix response format; formatting --- app/config/frameworks.php | 7 ++++--- .../Modules/Sites/Http/Sites/CreateSite.php | 1 - .../Utopia/Response/Model/Framework.php | 21 +++++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/config/frameworks.php b/app/config/frameworks.php index c553636d48..b4f3998851 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -4,7 +4,7 @@ * List of Appwrite Sites supported frameworks */ - const TEMPLATE_RUNTIMES = [ +const TEMPLATE_RUNTIMES = [ 'NODE' => [ 'name' => 'node', 'versions' => ['22', '21.0', '20.0', '19.0', '18.0', '16.0', '14.5'] @@ -39,11 +39,12 @@ ], ]; - function getVersions(array $versions, string $prefix) { +function getVersions(array $versions, string $prefix) +{ return array_map(function ($version) use ($prefix) { return $prefix . '-' . $version; }, $versions); - } +} return [ 'sveltekit' => [ diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index 6c62f02fe6..65666dddd1 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -23,7 +23,6 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Swoole\Request; use Utopia\System\System; -use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; diff --git a/src/Appwrite/Utopia/Response/Model/Framework.php b/src/Appwrite/Utopia/Response/Model/Framework.php index ddd6322553..b23e73896a 100644 --- a/src/Appwrite/Utopia/Response/Model/Framework.php +++ b/src/Appwrite/Utopia/Response/Model/Framework.php @@ -34,17 +34,30 @@ class Framework extends Model 'default' => '', 'example' => 'sveltekit.png', ]) - ->addRule('defaultRuntime', [ + ->addRule('defaultServeRuntime', [ 'type' => self::TYPE_STRING, 'description' => 'Default runtime version.', 'default' => '', - 'example' => 'node-20.0', + 'example' => 'static-1', ]) - ->addRule('runtimes', [ + ->addRule('serveRuntimes', [ 'type' => self::TYPE_STRING, 'description' => 'List of supported runtime versions.', 'default' => '', - 'example' => 'node-16.0', + 'example' => 'static-1', + 'array' => true, + ]) + ->addRule('defaultBuildRuntime', [ + 'type' => self::TYPE_STRING, + 'description' => 'Default runtime version.', + 'default' => '', + 'example' => 'node-22', + ]) + ->addRule('buildRuntimes', [ + 'type' => self::TYPE_STRING, + 'description' => 'List of supported runtime versions.', + 'default' => '', + 'example' => 'node-21.0', 'array' => true, ]) ; From d8610e0f2ae98ccf9c373f0d8a6334dd05125b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 26 Oct 2024 18:57:37 +0000 Subject: [PATCH 06/14] Upgrade executor to fix tests --- app/views/install/compose.phtml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 27180750b6..ddbc1e9aa3 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -795,7 +795,7 @@ $image = $this->getParam('image', ''); <<: *x-logging restart: unless-stopped stop_signal: SIGINT - image: openruntimes/executor:0.6.24 + image: openruntimes/executor:0.6.25 networks: - appwrite - runtimes diff --git a/docker-compose.yml b/docker-compose.yml index dc58d0c3c0..d5fbc8fe02 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -881,7 +881,7 @@ services: hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.6.24 + image: openruntimes/executor:0.6.25 restart: unless-stopped networks: - appwrite From 86a68c50bcc62e9caf69c610bcf7dedada986e3e Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:32:43 +0100 Subject: [PATCH 07/14] Rename subdomain --- .../Platform/Modules/Sites/Http/Sites/CreateSite.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index 77d4ec70a1..2db8cf68a3 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -64,7 +64,7 @@ class CreateSite extends Base ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('fallbackRedirect', '', new Text(8192, 0), 'Fallback Redirect URL for site in case a route is not found.', true) - ->param('subDomain', '', new CustomId(), 'Unique custom sub-domain. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true) + ->param('subdomain', '', new CustomId(), 'Unique custom sub-domain. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) ->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the site.', true) @@ -92,7 +92,7 @@ class CreateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $subDomain, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $subdomain, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) { $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $ruleId = ''; @@ -101,14 +101,14 @@ class CreateSite extends Base if (!empty($sitesDomain)) { $ruleId = ID::unique(); - $routeSubdomain = $subDomain ?? ID::unique(); + $routeSubdomain = $subdomain ?? ID::unique(); $domain = "{$routeSubdomain}.{$sitesDomain}"; - $subDomain = Authorization::skip(fn () => $dbForConsole->findOne('rules', [ + $subdomain = Authorization::skip(fn () => $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain]) ])); - if (!empty($subDomain)) { + if (!empty($subdomain)) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Subdomain already exists. Please choose a different subdomain.'); } } From 6b2160f3882443fe469055c8071058c3033f0047 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:33:56 +0100 Subject: [PATCH 08/14] Fix vcs deployments --- app/controllers/api/vcs.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 753fd043c8..9021c6c518 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -200,11 +200,10 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'resourceInternalId' => $resourceInternalId, 'resourceType' => $resourceCollection, 'entrypoint' => $resource->getAttribute('entrypoint', ''), - 'commands' => $resource->getAttribute('commands', []), + 'commands' => $resource->getAttribute('commands', ''), 'installCommand' => $resource->getAttribute('installCommand', ''), 'buildCommand' => $resource->getAttribute('buildCommand', ''), 'outputDirectory' => $resource->getAttribute('outputDirectory', ''), - 'fallbackRedirect' => $resource->getAttribute('fallbackRedirect', ''), 'type' => 'vcs', 'installationId' => $installationId, 'installationInternalId' => $installationInternalId, From 302a135e5a79ffcf64cedc96ee9c37f41d8b5ac6 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:52:22 +0100 Subject: [PATCH 09/14] Fix health tests --- tests/e2e/Services/Health/HealthCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Health/HealthCustomServerTest.php b/tests/e2e/Services/Health/HealthCustomServerTest.php index 8360af542e..7a8b3ab7cb 100644 --- a/tests/e2e/Services/Health/HealthCustomServerTest.php +++ b/tests/e2e/Services/Health/HealthCustomServerTest.php @@ -467,7 +467,7 @@ class HealthCustomServerTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals('/CN=appwrite.io', $response['body']['name']); $this->assertEquals('appwrite.io', $response['body']['subjectSN']); - $this->assertEquals("Let's Encrypt", $response['body']['issuerOrganisation']); + $this->assertEquals('Google Trust Services', $response['body']['issuerOrganisation']); $this->assertIsInt($response['body']['validFrom']); $this->assertIsInt($response['body']['validTo']); From 83807ed2479db7b4f8048a300b12b99e89ac78b3 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:56:56 +0100 Subject: [PATCH 10/14] Fix projects tests --- app/controllers/api/proxy.php | 20 ++++++------------- .../Projects/ProjectsCustomServerTest.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index d749946826..3411ebafd5 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -54,19 +54,12 @@ App::post('/v1/proxy/rules') $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); - switch ($resourceType) { - case 'function': - if (str_ends_with($domain, $functionsDomain)) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.'); - } - break; - case 'site': - if (str_ends_with($domain, $sitesDomain)) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.'); - } - break; + if ($functionsDomain != '' && str_ends_with($domain, $functionsDomain)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.'); + } + if ($sitesDomain != '' && str_ends_with($domain, $sitesDomain)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your sites domain or it\'s subdomain to specific resource. Please use different domain.'); } - if ($domain === 'localhost' || $domain === APP_HOSTNAME_INTERNAL) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'This domain name is not allowed. Please pick another one.'); @@ -111,8 +104,7 @@ App::post('/v1/proxy/rules') break; case 'site': if (empty($resourceId)) { - // todo: use site relecant exception - throw new Exception(Exception::FUNCTION_NOT_FOUND); + throw new Exception(Exception::SITE_NOT_FOUND); } $site = $dbForProject->getDocument('sites', $resourceId); diff --git a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php index cc976b78f6..f81290e707 100644 --- a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php +++ b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php @@ -44,5 +44,15 @@ class ProjectsCustomServerTest extends Scope ]); $this->assertEquals(400, $response['headers']['status-code']); + + // prevent sites domain + $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); + + $response = $this->client->call(Client::METHOD_POST, '/proxy/rules', $headers, [ + 'resourceType' => 'api', + 'domain' => $sitesDomain, + ]); + + $this->assertEquals(400, $response['headers']['status-code']); } } From 0c2db53ee8d41d05545b616da9aafa4667f99d26 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:11:53 +0100 Subject: [PATCH 11/14] Address PR Comments --- app/controllers/api/proxy.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 3411ebafd5..ada8d2453c 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -54,11 +54,12 @@ App::post('/v1/proxy/rules') $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); - if ($functionsDomain != '' && str_ends_with($domain, $functionsDomain)) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.'); - } - if ($sitesDomain != '' && str_ends_with($domain, $sitesDomain)) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your sites domain or it\'s subdomain to specific resource. Please use different domain.'); + if ( + ($functionsDomain !== '' && str_ends_with($domain, $functionsDomain)) || + ($sitesDomain !== '' && str_ends_with($domain, $sitesDomain)) + ) { + // TODO: Refactor later + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions or sites domain or their subdomains to a specific resource. Please use a different domain.'); } if ($domain === 'localhost' || $domain === APP_HOSTNAME_INTERNAL) { From 77a70cad71b6ed40606d74ca5f853e6d9fd3d00d Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:31:00 +0100 Subject: [PATCH 12/14] Add endpoint to check subdomain availability --- app/controllers/api/proxy.php | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index ada8d2453c..56982bee38 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -371,3 +371,39 @@ App::patch('/v1/proxy/rules/:ruleId/verification') $response->dynamic($rule, Response::MODEL_PROXY_RULE); }); + +App::get('/v1/proxy/subdomains') + ->desc('Check if subdomain is available') + ->groups(['api', 'proxy']) + ->label('scope', 'rules.read') + ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) + ->label('sdk.namespace', 'proxy') + ->label('sdk.method', 'checkSubdomain') + ->label('sdk.description', '/docs/references/proxy/check-subdomain.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_NONE) + ->param('resourceType', null, new WhiteList(['function', 'site']), 'Action definition for the rule. Possible values are "api", "function" and "site"') + ->param('subdomain', '', new Text(256), 'Subdomain name.') + ->inject('response') + ->inject('dbForConsole') + ->action(function (string $resourceType, string $subdomain, Response $response, Database $dbForConsole) { + $resourceDomain = $resourceType === 'site' ? System::getEnv('_APP_DOMAIN_SITES', '') : System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); + $domain = $subdomain . '.' . $resourceDomain; + + $document = $dbForConsole->findOne('rules', [ + Query::equal('domain', [$domain]), + ]); + + if ($document && !$document->isEmpty()) { + return $response->json([ + 'success' => false, + 'message' => 'Subdomain is already taken.' + ], Response::STATUS_CODE_CONFLICT); + } + + return $response->json([ + 'success' => true, + 'message' => 'Subdomain is available.' + ], Response::STATUS_CODE_OK); + }); From e7e1cfa12eec30f014dcbf56bf71d2a9d8dee82f Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:32:29 +0100 Subject: [PATCH 13/14] Update desc --- app/controllers/api/proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 56982bee38..aee3df9235 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -383,7 +383,7 @@ App::get('/v1/proxy/subdomains') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_NONE) - ->param('resourceType', null, new WhiteList(['function', 'site']), 'Action definition for the rule. Possible values are "api", "function" and "site"') + ->param('resourceType', null, new WhiteList(['function', 'site']), 'Action definition for the rule. Possible values are "function" and "site"') ->param('subdomain', '', new Text(256), 'Subdomain name.') ->inject('response') ->inject('dbForConsole') From 44e76b4eaaae22047201bd18ed592ec85acd7aba Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:35:18 +0100 Subject: [PATCH 14/14] Add a todo --- app/controllers/api/proxy.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index aee3df9235..3b061a85c2 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -388,6 +388,7 @@ App::get('/v1/proxy/subdomains') ->inject('response') ->inject('dbForConsole') ->action(function (string $resourceType, string $subdomain, Response $response, Database $dbForConsole) { + //TODO: Add tests for this endpoint $resourceDomain = $resourceType === 'site' ? System::getEnv('_APP_DOMAIN_SITES', '') : System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); $domain = $subdomain . '.' . $resourceDomain;