From 9b77dc246993b962eb905a283d6e3a7642483d25 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 9 Aug 2021 21:34:34 +0300 Subject: [PATCH] feat(endpoints): update utils endpoint --- src/flextype/Endpoints/utils.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/flextype/Endpoints/utils.php b/src/flextype/Endpoints/utils.php index 41c294b2..b9e7abc3 100644 --- a/src/flextype/Endpoints/utils.php +++ b/src/flextype/Endpoints/utils.php @@ -35,7 +35,7 @@ app()->post('/api/utils/cache/clear', function (ServerRequestInterface $request, // Get Query Params $data = $request->getParsedBody(); - // Check is images api enabled + // Check is utils api enabled if (! registry()->get('flextype.settings.api.utils.enabled')) { return getApiResponseWithError($response, 400); } @@ -65,11 +65,14 @@ app()->post('/api/utils/cache/clear', function (ServerRequestInterface $request, } // Update token calls - tokens()->update($data['token'], ['calls' => $data['calls'] + 1]); + tokens()->update($data['token'], ['calls' => $tokenData['calls'] + 1]); // Clear cache filesystem()->directory(PATH['tmp'])->delete(); // Return success response - return ; + $response->getBody()->write(serializers()->json()->encode(['Cache cleared.'])); + $response->withStatus(200); + $response->withHeader('Content-Type', 'application/json;charset=' . registry()->get('flextype.settings.charset')); + return $response; });