1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(endpoints): update utils endpoint

This commit is contained in:
Awilum
2021-08-09 21:34:34 +03:00
parent e3e3b571ae
commit 9b77dc2469

View File

@@ -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;
});