From d2008d33a5c49efeb39be158d6d826f03b97ef09 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Mon, 2 May 2022 14:28:36 +0000 Subject: [PATCH 1/3] refactor health.php --- app/controllers/api/health.php | 48 ++++++++++++---------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index bc57aa8ccb..b805958c14 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -1,6 +1,8 @@ label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_STATUS) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $output = [ 'status' => 'pass', @@ -40,8 +41,7 @@ App::get('/v1/health/version') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_VERSION) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $response->dynamic(new Document([ 'version' => APP_VERSION_STABLE ]), Response::MODEL_HEALTH_VERSION); }); @@ -59,9 +59,7 @@ App::get('/v1/health/db') ->label('sdk.response.model', Response::MODEL_HEALTH_STATUS) ->inject('response') ->inject('utopia') - ->action(function ($response, $utopia) { - /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\App $utopia */ + ->action(function (Response $response, App $utopia) { $checkStart = \microtime(true); @@ -99,10 +97,7 @@ App::get('/v1/health/cache') ->label('sdk.response.model', Response::MODEL_HEALTH_STATUS) ->inject('response') ->inject('utopia') - ->action(function ($response, $utopia) { - /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\App $utopia */ - /** @var Redis */ + ->action(function (Response $response, App $utopia) { $checkStart = \microtime(true); @@ -132,8 +127,7 @@ App::get('/v1/health/time') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_TIME) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { /* * Code from: @see https://www.beliefmedia.com.au/query-ntp-time-server @@ -190,8 +184,7 @@ App::get('/v1/health/queue/webhooks') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $response->dynamic(new Document([ 'size' => Resque::size(Event::WEBHOOK_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); @@ -208,8 +201,7 @@ App::get('/v1/health/queue/logs') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $response->dynamic(new Document([ 'size' => Resque::size(Event::AUDITS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); @@ -226,8 +218,7 @@ App::get('/v1/health/queue/usage') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $response->dynamic(new Document([ 'size' => Resque::size(Event::USAGE_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); @@ -244,8 +235,7 @@ App::get('/v1/health/queue/certificates') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $response->dynamic(new Document([ 'size' => Resque::size(Event::CERTIFICATES_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); @@ -262,8 +252,7 @@ App::get('/v1/health/queue/functions') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $response->dynamic(new Document([ 'size' => Resque::size(Event::FUNCTIONS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); @@ -280,8 +269,7 @@ App::get('/v1/health/storage/local') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_STATUS) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $checkStart = \microtime(true); @@ -322,8 +310,7 @@ App::get('/v1/health/anti-virus') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_ANTIVIRUS) ->inject('response') - ->action(function ($response) { - /** @var Appwrite\Utopia\Response $response */ + ->action(function (Response $response) { $output = [ 'status' => '', @@ -359,10 +346,7 @@ App::get('/v1/health/stats') // Currently only used internally ->inject('response') ->inject('register') ->inject('deviceFiles') - ->action(function ($response, $register, $deviceFiles) { - /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\Registry\Registry $register */ - /** @var Utopia\Storage\Device $deviceFiles */ + ->action(function (Response $response, Registry $register, Device $deviceFiles) { $cache = $register->get('cache'); From fd3a802a305c80993bd66b4dda04f699d13348e4 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Mon, 2 May 2022 14:34:01 +0000 Subject: [PATCH 2/3] regroup namespaces --- app/controllers/api/health.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index b805958c14..d51ed6a458 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -1,15 +1,15 @@ desc('Get HTTP') From 2729237edcbea31ec6cc9270be68a0dccf71cb80 Mon Sep 17 00:00:00 2001 From: Everly Precia Suresh Date: Mon, 2 May 2022 15:04:14 +0000 Subject: [PATCH 3/3] retrigger build --- app/controllers/api/health.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index d51ed6a458..2ca66e24ba 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -9,7 +9,7 @@ use Utopia\Database\Document; use Utopia\Registry\Registry; use Utopia\Storage\Device; use Utopia\Storage\Device\Local; -use Utopia\Storage\Storage; +use Utopia\Storage\Storage; App::get('/v1/health') ->desc('Get HTTP')