mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
tidy up
This commit is contained in:
+1
-3
@@ -10,6 +10,4 @@
|
||||
debug/
|
||||
app/sdks
|
||||
dev/yasd_init.php
|
||||
test/tmp/
|
||||
tests/resources/disk-a/video-srt.srt
|
||||
tests/resources/disk-a/video-srt.mp4
|
||||
|
||||
|
||||
@@ -2783,11 +2783,9 @@ $collections = [
|
||||
],
|
||||
'indexes' => [
|
||||
[
|
||||
'$id' => '_key_accessed',
|
||||
'$id' => '_key_accessedAt',
|
||||
'type' => Database::INDEX_KEY,
|
||||
'attributes' => ['accessedAt'],
|
||||
'lengths' => [],
|
||||
'orders' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -55,7 +55,8 @@ $avatarCallback = function (string $type, string $code, int $width, int $height,
|
||||
|
||||
App::get('/v1/avatars/credit-cards/:code')
|
||||
->desc('Get Credit Card Icon')
|
||||
->groups(['api', 'avatars', 'cache'])
|
||||
->groups(['api', 'avatars'])
|
||||
->label('cache', true)
|
||||
->label('scope', 'avatars.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
@@ -73,7 +74,8 @@ App::get('/v1/avatars/credit-cards/:code')
|
||||
|
||||
App::get('/v1/avatars/browsers/:code')
|
||||
->desc('Get Browser Icon')
|
||||
->groups(['api', 'avatars', 'cache'])
|
||||
->groups(['api', 'avatars'])
|
||||
->label('cache', true)
|
||||
->label('scope', 'avatars.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
@@ -91,7 +93,8 @@ App::get('/v1/avatars/browsers/:code')
|
||||
|
||||
App::get('/v1/avatars/flags/:code')
|
||||
->desc('Get Country Flag')
|
||||
->groups(['api', 'avatars', 'cache'])
|
||||
->groups(['api', 'avatars'])
|
||||
->label('cache', true)
|
||||
->label('scope', 'avatars.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
@@ -110,6 +113,7 @@ App::get('/v1/avatars/flags/:code')
|
||||
App::get('/v1/avatars/image')
|
||||
->desc('Get Image from URL')
|
||||
->groups(['api', 'avatars'])
|
||||
->label('cache', true)
|
||||
->label('scope', 'avatars.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
@@ -156,7 +160,8 @@ App::get('/v1/avatars/image')
|
||||
|
||||
App::get('/v1/avatars/favicon')
|
||||
->desc('Get Favicon')
|
||||
->groups(['api', 'avatars', 'cache'])
|
||||
->groups(['api', 'avatars'])
|
||||
->label('cache', true)
|
||||
->label('scope', 'avatars.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
|
||||
@@ -800,8 +800,8 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId')
|
||||
App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
|
||||
->alias('/v1/storage/files/:fileId/preview', ['bucketId' => 'default'])
|
||||
->desc('Get File Preview')
|
||||
->groups(['api', 'storage', 'cache'])
|
||||
->label('useCache', true)
|
||||
->groups(['api', 'storage'])
|
||||
->label('cache', true)
|
||||
->label('scope', 'files.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
|
||||
->label('sdk.namespace', 'storage')
|
||||
|
||||
@@ -612,7 +612,6 @@ App::get('/.well-known/acme-challenge')
|
||||
});
|
||||
|
||||
include_once __DIR__ . '/shared/api.php';
|
||||
include_once __DIR__ . '/shared/cache.php';
|
||||
include_once __DIR__ . '/shared/web.php';
|
||||
|
||||
foreach (Config::getParam('services', []) as $service) {
|
||||
|
||||
@@ -47,7 +47,6 @@ App::init(function (App $utopia, Request $request, Response $response, Document
|
||||
}
|
||||
|
||||
$closestLimit = null;
|
||||
|
||||
$roles = Authorization::getRoles();
|
||||
$isPrivilegedUser = Auth::isPrivilegedUser($roles);
|
||||
$isAppUser = Auth::isAppUser($roles);
|
||||
@@ -116,7 +115,7 @@ App::init(function (App $utopia, Request $request, Response $response, Document
|
||||
$deletes->setProject($project);
|
||||
$database->setProject($project);
|
||||
|
||||
$useCache = $route->getLabel('useCache', false);
|
||||
$useCache = $route->getLabel('cache', false);
|
||||
if ($useCache) {
|
||||
$key = md5($request->getURI() . $request->getServer('query_string'));
|
||||
$cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()));
|
||||
@@ -133,7 +132,11 @@ App::init(function (App $utopia, Request $request, Response $response, Document
|
||||
Authorization::skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), $cacheLog));
|
||||
}
|
||||
$data = json_decode($data, true);
|
||||
$response->file(base64_decode($data['payload']), $data['content-type'], $data['date'], 'hit');
|
||||
$response->setContentType($data['content-type'])
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache
|
||||
->addHeader('Expires', $data['date'])
|
||||
->addHeader('X-Appwrite-Cache', 'hit')
|
||||
->file(base64_decode($data['payload']));
|
||||
}
|
||||
}
|
||||
}, ['utopia', 'request', 'response', 'project', 'user', 'events', 'audits', 'mails', 'usage', 'deletes', 'database', 'dbForProject', 'mode'], 'api');
|
||||
@@ -261,7 +264,7 @@ App::shutdown(function (App $utopia, Request $request, Response $response, Docum
|
||||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
$useCache = $route->getLabel('useCache', false);
|
||||
$useCache = $route->getLabel('cache', false);
|
||||
if ($useCache) {
|
||||
$key = md5($request->getURI() . $request->getServer('query_string'));
|
||||
$cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()));
|
||||
|
||||
@@ -695,8 +695,6 @@ App::setResource('layout', function ($locale) {
|
||||
return $layout;
|
||||
}, ['locale']);
|
||||
|
||||
App::setResource('cacheKey', fn () => '');
|
||||
App::setResource('cachePath', fn () => '');
|
||||
App::setResource('locale', fn() => new Locale(App::getEnv('_APP_LOCALE', 'en')));
|
||||
|
||||
// Queues
|
||||
|
||||
@@ -381,7 +381,7 @@ class Response extends SwooleResponse
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
public function output(Document $document, string $model): string | array
|
||||
public function output(Document $document, string $model): array
|
||||
{
|
||||
$data = $document;
|
||||
$model = $this->getModel($model);
|
||||
@@ -453,10 +453,7 @@ class Response extends SwooleResponse
|
||||
'payload' => $data
|
||||
];
|
||||
|
||||
$this->setContentType($contentType)
|
||||
->addHeader('Expires', $date)
|
||||
->addHeader('X-Appwrite-Cache', $state)
|
||||
->send($data);
|
||||
$this->send($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user