From e866a352a776e482e1859445cdaaf40330746e89 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 10 Jan 2022 14:13:23 +0000 Subject: [PATCH] Implement Suggestions --- app/controllers/api/functions.php | 6 ++++-- app/executor.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 00f966080e..519f857232 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -305,6 +305,7 @@ App::put('/v1/functions/:functionId') /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForProject */ /** @var Utopia\Database\Document $project */ + /** @var Appwrite\Auth\User $user */ $function = $dbForProject->getDocument('functions', $functionId); @@ -426,6 +427,7 @@ App::delete('/v1/functions/:functionId') /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForProject */ /** @var Appwrite\Event\Event $deletes */ + /** @var Utopia\Database\Document $project */ $function = $dbForProject->getDocument('functions', $functionId); @@ -550,7 +552,7 @@ App::post('/v1/functions/:functionId/tags') throw new Exception('Failed moving file', 500); } - if ($automaticDeploy === 'true') { + if ((bool) $automaticDeploy) { // Remove automaticDeploy for all other tags. $tags = $dbForProject->find('tags', [ new Query('automaticDeploy', Query::TYPE_EQUAL, [true]), @@ -786,7 +788,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId') $error = \curl_error($ch); if (!empty($error)) { - throw new Exception('Curl error: ' . $error, 500); + throw new Exception('Executor Cleanup error: ' . $error, 500); } // Check status code diff --git a/app/executor.php b/app/executor.php index 5b997d7249..3153becbf5 100644 --- a/app/executor.php +++ b/app/executor.php @@ -90,6 +90,7 @@ $executionEnd = \microtime(true); Console::info(count($activeFunctions) . ' functions listed in ' . ($executionEnd - $executionStart) . ' seconds'); App::post('/v1/execute') // Define Route + ->desc('Execute a function') ->inject('request') ->param('trigger', '', new Text(1024)) ->param('projectId', '', new Text(1024)) @@ -351,11 +352,10 @@ App::post('/v1/tag') $response->dynamic($function, Response::MODEL_FUNCTION); }); -App::get('/v1/healthz') +App::get('/v1/') ->inject('request') ->inject('response') - ->action( - function ($request, $response) { + ->action(function ($request, $response) { $response ->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate') ->addHeader('Expires', '0')