1
0
Fork 0
mirror of synced 2024-05-20 04:32:37 +12:00

Upgraded FW

This commit is contained in:
Eldad Fux 2020-06-28 20:31:21 +03:00
parent 19a17f4568
commit 00e3632c59
20 changed files with 249 additions and 234 deletions

View file

@ -50,7 +50,7 @@ $clients = \array_unique(\array_merge($clientsConsole, \array_map(function ($nod
return false;
}))));
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $webhook, $audit, $usage, $clients) {
App::init(function () use ($utopia, $request, $response, &$user, $project, $console, $webhook, $audit, $usage, $clients) {
$route = $utopia->match($request);
@ -79,7 +79,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
* As recommended at:
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
*/
if ($utopia->getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if(Config::getParam('protocol') !== 'https') {
return $response->redirect('https://' . Config::getParam('domain').$request->getServer('REQUEST_URI'));
}
@ -224,7 +224,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
;
});
$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $deletes, $mode, $project, $utopia) {
App::shutdown(function () use ($response, $request, $webhook, $audit, $usage, $deletes, $mode, $project, $utopia) {
/*
* Trigger events for background workers
@ -254,7 +254,7 @@ $utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage
}
});
$utopia->options(function () use ($request, $response) {
App::options(function () use ($request, $response) {
$origin = $request->getServer('HTTP_ORIGIN');
$response
@ -266,7 +266,7 @@ $utopia->options(function () use ($request, $response) {
->send();
});
$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project) {
App::error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project) {
$env = Config::getParam('env');
$version = Config::getParam('version');
@ -339,7 +339,7 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
;
});
$utopia->get('/manifest.json')
App::get('/manifest.json')
->desc('Progressive app manifest file')
->label('scope', 'public')
->label('docs', false)
@ -365,7 +365,7 @@ $utopia->get('/manifest.json')
}
);
$utopia->get('/robots.txt')
App::get('/robots.txt')
->desc('Robots.txt File')
->label('scope', 'public')
->label('docs', false)
@ -376,7 +376,7 @@ $utopia->get('/robots.txt')
}
);
$utopia->get('/humans.txt')
App::get('/humans.txt')
->desc('Humans.txt File')
->label('scope', 'public')
->label('docs', false)
@ -387,7 +387,7 @@ $utopia->get('/humans.txt')
}
);
$utopia->get('/.well-known/acme-challenge')
App::get('/.well-known/acme-challenge')
->desc('SSL Verification')
->label('scope', 'public')
->label('docs', false)

View file

@ -1,7 +1,8 @@
<?php
global $utopia, $request;
global $request;
use Utopia\App;
use Utopia\Config\Config;
use Appwrite\Database\Database;
@ -50,9 +51,9 @@ $collections = [
'legalCity' => '',
'legalAddress' => '',
'legalTaxId' => '',
'authWhitelistEmails' => (!empty($utopia->getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', $utopia->getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [],
'authWhitelistIPs' => (!empty($utopia->getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', $utopia->getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [],
'authWhitelistDomains' => (!empty($utopia->getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null))) ? \explode(',', $utopia->getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null)) : [],
'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [],
'authWhitelistIPs' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [],
'authWhitelistDomains' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null)) : [],
],
Database::SYSTEM_COLLECTION_COLLECTIONS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,

View file

@ -3,6 +3,7 @@
global $utopia, $register, $request, $response, $user, $audit,
$webhook, $mail, $project, $projectDB, $clients;
use Utopia\App;
use Utopia\Exception;
use Utopia\Response;
use Utopia\Config\Config;
@ -34,7 +35,7 @@ $oauthDefaultFailure = '/auth/oauth2/failure';
$oauth2Keys = [];
$utopia->init(function() use (&$oauth2Keys) {
App::init(function() use (&$oauth2Keys) {
foreach (Config::getParam('providers') as $key => $provider) {
if (!$provider['enabled']) {
continue;
@ -45,7 +46,7 @@ $utopia->init(function() use (&$oauth2Keys) {
}
}, 'account');
$utopia->post('/v1/account')
App::post('/v1/account')
->desc('Create Account')
->groups(['api', 'account'])
->label('webhook', 'account.create')
@ -146,7 +147,7 @@ $utopia->post('/v1/account')
}
);
$utopia->post('/v1/account/sessions')
App::post('/v1/account/sessions')
->desc('Create Account Session')
->groups(['api', 'account'])
->label('webhook', 'account.sessions.create')
@ -237,7 +238,7 @@ $utopia->post('/v1/account/sessions')
}
);
$utopia->get('/v1/account/sessions/oauth2/:provider')
App::get('/v1/account/sessions/oauth2/:provider')
->desc('Create Account Session with OAuth2')
->groups(['api', 'account'])
->label('error', __DIR__.'/../../views/general/error.phtml')
@ -265,7 +266,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider')
$appSecret = \json_decode($appSecret, true);
if (!empty($appSecret) && isset($appSecret['version'])) {
$key = $utopia->getEnv('_APP_OPENSSL_KEY_V'.$appSecret['version']);
$key = App::getEnv('_APP_OPENSSL_KEY_V'.$appSecret['version']);
$appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag']));
}
@ -288,7 +289,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider')
}
);
$utopia->get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
->groups(['api', 'account'])
->label('error', __DIR__.'/../../views/general/error.phtml')
@ -311,7 +312,7 @@ $utopia->get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
}
);
$utopia->post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
->groups(['api', 'account'])
->label('error', __DIR__.'/../../views/general/error.phtml')
@ -335,7 +336,7 @@ $utopia->post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
}
);
$utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
App::get('/v1/account/sessions/oauth2/:provider/redirect')
->desc('OAuth2 Redirect')
->groups(['api', 'account'])
->label('error', __DIR__.'/../../views/general/error.phtml')
@ -360,7 +361,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
$appSecret = \json_decode($appSecret, true);
if (!empty($appSecret) && isset($appSecret['version'])) {
$key = $utopia->getEnv('_APP_OPENSSL_KEY_V'.$appSecret['version']);
$key = App::getEnv('_APP_OPENSSL_KEY_V'.$appSecret['version']);
$appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag']));
}
@ -531,7 +532,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
}
);
$utopia->get('/v1/account')
App::get('/v1/account')
->desc('Get Account')
->groups(['api', 'account'])
->label('scope', 'account')
@ -555,7 +556,7 @@ $utopia->get('/v1/account')
}
);
$utopia->get('/v1/account/prefs')
App::get('/v1/account/prefs')
->desc('Get Account Preferences')
->groups(['api', 'account'])
->label('scope', 'account')
@ -578,7 +579,7 @@ $utopia->get('/v1/account/prefs')
}
);
$utopia->get('/v1/account/sessions')
App::get('/v1/account/sessions')
->desc('Get Account Sessions')
->groups(['api', 'account'])
->label('scope', 'account')
@ -637,7 +638,7 @@ $utopia->get('/v1/account/sessions')
}
);
$utopia->get('/v1/account/logs')
App::get('/v1/account/logs')
->desc('Get Account Logs')
->groups(['api', 'account'])
->label('scope', 'account')
@ -710,7 +711,7 @@ $utopia->get('/v1/account/logs')
}
);
$utopia->patch('/v1/account/name')
App::patch('/v1/account/name')
->desc('Update Account Name')
->groups(['api', 'account'])
->label('webhook', 'account.update.name')
@ -748,7 +749,7 @@ $utopia->patch('/v1/account/name')
}
);
$utopia->patch('/v1/account/password')
App::patch('/v1/account/password')
->desc('Update Account Password')
->groups(['api', 'account'])
->label('webhook', 'account.update.password')
@ -791,7 +792,7 @@ $utopia->patch('/v1/account/password')
}
);
$utopia->patch('/v1/account/email')
App::patch('/v1/account/email')
->desc('Update Account Email')
->groups(['api', 'account'])
->label('webhook', 'account.update.email')
@ -850,7 +851,7 @@ $utopia->patch('/v1/account/email')
}
);
$utopia->patch('/v1/account/prefs')
App::patch('/v1/account/prefs')
->desc('Update Account Preferences')
->groups(['api', 'account'])
->label('webhook', 'account.update.prefs')
@ -891,7 +892,7 @@ $utopia->patch('/v1/account/prefs')
}
);
$utopia->delete('/v1/account')
App::delete('/v1/account')
->desc('Delete Account')
->groups(['api', 'account'])
->label('webhook', 'account.delete')
@ -947,7 +948,7 @@ $utopia->delete('/v1/account')
}
);
$utopia->delete('/v1/account/sessions/:sessionId')
App::delete('/v1/account/sessions/:sessionId')
->desc('Delete Account Session')
->groups(['api', 'account'])
->label('scope', 'account')
@ -1007,7 +1008,7 @@ $utopia->delete('/v1/account/sessions/:sessionId')
}
);
$utopia->delete('/v1/account/sessions')
App::delete('/v1/account/sessions')
->desc('Delete All Account Sessions')
->groups(['api', 'account'])
->label('scope', 'account')
@ -1058,7 +1059,7 @@ $utopia->delete('/v1/account/sessions')
}
);
$utopia->post('/v1/account/recovery')
App::post('/v1/account/recovery')
->desc('Create Password Recovery')
->groups(['api', 'account'])
->label('scope', 'public')
@ -1158,7 +1159,7 @@ $utopia->post('/v1/account/recovery')
}
);
$utopia->put('/v1/account/recovery')
App::put('/v1/account/recovery')
->desc('Complete Password Recovery')
->groups(['api', 'account'])
->label('scope', 'public')
@ -1229,7 +1230,7 @@ $utopia->put('/v1/account/recovery')
}
);
$utopia->post('/v1/account/verification')
App::post('/v1/account/verification')
->desc('Create Email Verification')
->groups(['api', 'account'])
->label('scope', 'account')
@ -1316,7 +1317,7 @@ $utopia->post('/v1/account/verification')
}
);
$utopia->put('/v1/account/verification')
App::put('/v1/account/verification')
->desc('Complete Email Verification')
->groups(['api', 'account'])
->label('scope', 'public')

View file

@ -2,6 +2,7 @@
global $utopia, $request, $response;
use Utopia\App;
use Utopia\Exception;
use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
@ -81,7 +82,7 @@ $avatarCallback = function ($type, $code, $width, $height, $quality) use ($respo
unset($resize);
};
$utopia->get('/v1/avatars/credit-cards/:code')
App::get('/v1/avatars/credit-cards/:code')
->desc('Get Credit Card Icon')
->groups(['api', 'avatars'])
->param('code', '', function () { return new WhiteList(\array_keys(Config::getParam('avatar-credit-cards'))); }, 'Credit Card Code. Possible values: '.\implode(', ', \array_keys(Config::getParam('avatar-credit-cards'))).'.')
@ -98,7 +99,7 @@ $utopia->get('/v1/avatars/credit-cards/:code')
return $avatarCallback('credit-cards', $code, $width, $height, $quality);
});
$utopia->get('/v1/avatars/browsers/:code')
App::get('/v1/avatars/browsers/:code')
->desc('Get Browser Icon')
->groups(['api', 'avatars'])
->param('code', '', function () { return new WhiteList(\array_keys(Config::getParam('avatar-browsers'))); }, 'Browser Code.')
@ -115,7 +116,7 @@ $utopia->get('/v1/avatars/browsers/:code')
return $avatarCallback('browsers', $code, $width, $height, $quality);
});
$utopia->get('/v1/avatars/flags/:code')
App::get('/v1/avatars/flags/:code')
->desc('Get Country Flag')
->groups(['api', 'avatars'])
->param('code', '', function () { return new WhiteList(\array_keys(Config::getParam('avatar-flags'))); }, 'Country Code. ISO Alpha-2 country code format.')
@ -132,7 +133,7 @@ $utopia->get('/v1/avatars/flags/:code')
return $avatarCallback('flags', $code, $width, $height, $quality);
});
$utopia->get('/v1/avatars/image')
App::get('/v1/avatars/image')
->desc('Get Image from URL')
->groups(['api', 'avatars'])
->param('url', '', function () { return new URL(); }, 'Image URL which you want to crop.')
@ -200,7 +201,7 @@ $utopia->get('/v1/avatars/image')
}
);
$utopia->get('/v1/avatars/favicon')
App::get('/v1/avatars/favicon')
->desc('Get Favicon')
->groups(['api', 'avatars'])
->param('url', '', function () { return new URL(); }, 'Website URL which you want to fetch the favicon from.')
@ -353,7 +354,7 @@ $utopia->get('/v1/avatars/favicon')
}
);
$utopia->get('/v1/avatars/qr')
App::get('/v1/avatars/qr')
->desc('Get QR Code')
->groups(['api', 'avatars'])
->param('text', '', function () { return new Text(512); }, 'Plain text to be converted to QR code image.')
@ -387,7 +388,7 @@ $utopia->get('/v1/avatars/qr')
}
);
$utopia->get('/v1/avatars/initials')
App::get('/v1/avatars/initials')
->desc('Get User Initials')
->groups(['api', 'avatars'])
->param('name', '', function () { return new Text(512); }, 'Full Name. When empty, current user name or email will be used.', true)

View file

@ -25,7 +25,7 @@ use Appwrite\Database\Exception\Structure as StructureException;
use DeviceDetector\DeviceDetector;
use GeoIp2\Database\Reader;
$utopia->post('/v1/database/collections')
App::post('/v1/database/collections')
->desc('Create Collection')
->groups(['api', 'database'])
->label('webhook', 'database.collections.create')
@ -99,7 +99,7 @@ $utopia->post('/v1/database/collections')
}
);
$utopia->get('/v1/database/collections')
App::get('/v1/database/collections')
->desc('List Collections')
->groups(['api', 'database'])
->label('scope', 'collections.read')
@ -148,7 +148,7 @@ $utopia->get('/v1/database/collections')
}
);
$utopia->get('/v1/database/collections/:collectionId')
App::get('/v1/database/collections/:collectionId')
->desc('Get Collection')
->groups(['api', 'database'])
->label('scope', 'collections.read')
@ -169,7 +169,7 @@ $utopia->get('/v1/database/collections/:collectionId')
}
);
// $utopia->get('/v1/database/collections/:collectionId/logs')
// App::get('/v1/database/collections/:collectionId/logs')
// ->desc('Get Collection Logs')
// ->groups(['api', 'database'])
// ->label('scope', 'collections.read')
@ -234,7 +234,7 @@ $utopia->get('/v1/database/collections/:collectionId')
// }
// );
$utopia->put('/v1/database/collections/:collectionId')
App::put('/v1/database/collections/:collectionId')
->desc('Update Collection')
->groups(['api', 'database'])
->label('scope', 'collections.write')
@ -307,7 +307,7 @@ $utopia->put('/v1/database/collections/:collectionId')
}
);
$utopia->delete('/v1/database/collections/:collectionId')
App::delete('/v1/database/collections/:collectionId')
->desc('Delete Collection')
->groups(['api', 'database'])
->label('scope', 'collections.write')
@ -345,7 +345,7 @@ $utopia->delete('/v1/database/collections/:collectionId')
}
);
$utopia->post('/v1/database/collections/:collectionId/documents')
App::post('/v1/database/collections/:collectionId/documents')
->desc('Create Document')
->groups(['api', 'database'])
->label('webhook', 'database.documents.create')
@ -465,7 +465,7 @@ $utopia->post('/v1/database/collections/:collectionId/documents')
}
);
$utopia->get('/v1/database/collections/:collectionId/documents')
App::get('/v1/database/collections/:collectionId/documents')
->desc('List Documents')
->groups(['api', 'database'])
->label('scope', 'documents.read')
@ -508,7 +508,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents')
if ($first || $last) {
$response->json((!empty($list) ? $list->getArrayCopy() : []));
} else {
if ($utopia->isDevelopment()) {
if (App::isDevelopment()) {
$collection
->setAttribute('debug', $projectDB->getDebug())
->setAttribute('limit', $limit)
@ -533,7 +533,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents')
}
);
$utopia->get('/v1/database/collections/:collectionId/documents/:documentId')
App::get('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Get Document')
->groups(['api', 'database'])
->label('scope', 'documents.read')
@ -579,7 +579,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents/:documentId')
}
);
$utopia->patch('/v1/database/collections/:collectionId/documents/:documentId')
App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Update Document')
->groups(['api', 'database'])
->label('webhook', 'database.documents.update')
@ -659,7 +659,7 @@ $utopia->patch('/v1/database/collections/:collectionId/documents/:documentId')
}
);
$utopia->delete('/v1/database/collections/:collectionId/documents/:documentId')
App::delete('/v1/database/collections/:collectionId/documents/:documentId')
->desc('Delete Document')
->groups(['api', 'database'])
->label('scope', 'documents.write')

View file

@ -2,6 +2,8 @@
global $utopia;
use Utopia\App;
/**
* TODO:
* 1. Map all objects, object-params, object-fields
@ -12,7 +14,7 @@ global $utopia;
* 6. Write tests!
*/
$utopia->post('/v1/graphql')
App::post('/v1/graphql')
->desc('GraphQL Endpoint')
->groups(['api', 'graphql'])
->label('scope', 'public')

View file

@ -2,12 +2,13 @@
global $utopia, $request, $response, $register;
use Utopia\App;
use Utopia\Exception;
use Appwrite\Storage\Device\Local;
use Appwrite\Storage\Storage;
use Appwrite\ClamAV\Network;
$utopia->get('/v1/health')
App::get('/v1/health')
->desc('Get HTTP')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -21,7 +22,7 @@ $utopia->get('/v1/health')
}
);
$utopia->get('/v1/health/version')
App::get('/v1/health/version')
->desc('Get Version')
->groups(['api', 'health'])
->label('scope', 'public')
@ -31,7 +32,7 @@ $utopia->get('/v1/health/version')
}
);
$utopia->get('/v1/health/db')
App::get('/v1/health/db')
->desc('Get DB')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -47,7 +48,7 @@ $utopia->get('/v1/health/db')
}
);
$utopia->get('/v1/health/cache')
App::get('/v1/health/cache')
->desc('Get Cache')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -63,7 +64,7 @@ $utopia->get('/v1/health/cache')
}
);
$utopia->get('/v1/health/time')
App::get('/v1/health/time')
->desc('Get Time')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -111,7 +112,7 @@ $utopia->get('/v1/health/time')
}
);
$utopia->get('/v1/health/queue/webhooks')
App::get('/v1/health/queue/webhooks')
->desc('Get Webhooks Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -125,7 +126,7 @@ $utopia->get('/v1/health/queue/webhooks')
}
);
$utopia->get('/v1/health/queue/tasks')
App::get('/v1/health/queue/tasks')
->desc('Get Tasks Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -139,7 +140,7 @@ $utopia->get('/v1/health/queue/tasks')
}
);
$utopia->get('/v1/health/queue/logs')
App::get('/v1/health/queue/logs')
->desc('Get Logs Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -153,7 +154,7 @@ $utopia->get('/v1/health/queue/logs')
}
);
$utopia->get('/v1/health/queue/usage')
App::get('/v1/health/queue/usage')
->desc('Get Usage Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -167,7 +168,7 @@ $utopia->get('/v1/health/queue/usage')
}
);
$utopia->get('/v1/health/queue/certificates')
App::get('/v1/health/queue/certificates')
->desc('Get Certificate Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -181,7 +182,7 @@ $utopia->get('/v1/health/queue/certificates')
}
);
$utopia->get('/v1/health/queue/functions')
App::get('/v1/health/queue/functions')
->desc('Get Functions Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -195,7 +196,7 @@ $utopia->get('/v1/health/queue/functions')
}
);
$utopia->get('/v1/health/storage/local')
App::get('/v1/health/storage/local')
->desc('Get Local Storage')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -226,7 +227,7 @@ $utopia->get('/v1/health/storage/local')
}
);
$utopia->get('/v1/health/anti-virus')
App::get('/v1/health/anti-virus')
->desc('Get Anti virus')
->groups(['api', 'health'])
->label('scope', 'health.read')
@ -249,7 +250,7 @@ $utopia->get('/v1/health/anti-virus')
}
);
$utopia->get('/v1/health/stats') // Currently only used internally
App::get('/v1/health/stats') // Currently only used internally
->desc('Get System Stats')
->groups(['api', 'health'])
->label('scope', 'god')

View file

@ -6,7 +6,7 @@ use Utopia\App;
use Utopia\Locale\Locale;
use GeoIp2\Database\Reader;
$utopia->get('/v1/locale')
App::get('/v1/locale')
->desc('Get User Locale')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@ -25,7 +25,7 @@ $utopia->get('/v1/locale')
$countries = Locale::getText('countries');
$continents = Locale::getText('continents');
if (App::MODE_TYPE_PRODUCTION !== $utopia->getMode()) {
if (!App::isProduction()) {
$ip = '79.177.241.94';
}
@ -65,7 +65,7 @@ $utopia->get('/v1/locale')
}
);
$utopia->get('/v1/locale/countries')
App::get('/v1/locale/countries')
->desc('List Countries')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@ -83,7 +83,7 @@ $utopia->get('/v1/locale/countries')
}
);
$utopia->get('/v1/locale/countries/eu')
App::get('/v1/locale/countries/eu')
->desc('List EU Countries')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@ -109,7 +109,7 @@ $utopia->get('/v1/locale/countries/eu')
}
);
$utopia->get('/v1/locale/countries/phones')
App::get('/v1/locale/countries/phones')
->desc('List Countries Phone Codes')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@ -135,7 +135,7 @@ $utopia->get('/v1/locale/countries/phones')
}
);
$utopia->get('/v1/locale/continents')
App::get('/v1/locale/continents')
->desc('List Continents')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@ -154,7 +154,7 @@ $utopia->get('/v1/locale/continents')
);
$utopia->get('/v1/locale/currencies')
App::get('/v1/locale/currencies')
->desc('List Currencies')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@ -171,7 +171,7 @@ $utopia->get('/v1/locale/currencies')
);
$utopia->get('/v1/locale/languages')
App::get('/v1/locale/languages')
->desc('List Languages')
->groups(['api', 'locale'])
->label('scope', 'locale.read')

View file

@ -2,6 +2,7 @@
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB, $deletes;
use Utopia\App;
use Utopia\Exception;
use Utopia\Response;
use Utopia\Validator\ArrayList;
@ -23,7 +24,7 @@ use Cron\CronExpression;
$scopes = include __DIR__.'/../../../app/config/scopes.php';
$utopia->post('/v1/projects')
App::post('/v1/projects')
->desc('Create Project')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -86,7 +87,7 @@ $utopia->post('/v1/projects')
}
);
$utopia->get('/v1/projects')
App::get('/v1/projects')
->desc('List Projects')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -120,7 +121,7 @@ $utopia->get('/v1/projects')
}
);
$utopia->get('/v1/projects/:projectId')
App::get('/v1/projects/:projectId')
->desc('Get Project')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -148,7 +149,7 @@ $utopia->get('/v1/projects/:projectId')
}
);
$utopia->get('/v1/projects/:projectId/usage')
App::get('/v1/projects/:projectId/usage')
->desc('Get Project')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -310,7 +311,7 @@ $utopia->get('/v1/projects/:projectId/usage')
}
);
$utopia->patch('/v1/projects/:projectId')
App::patch('/v1/projects/:projectId')
->desc('Update Project')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -356,7 +357,7 @@ $utopia->patch('/v1/projects/:projectId')
}
);
$utopia->patch('/v1/projects/:projectId/oauth2')
App::patch('/v1/projects/:projectId/oauth2')
->desc('Update Project OAuth2')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -398,7 +399,7 @@ $utopia->patch('/v1/projects/:projectId/oauth2')
}
);
$utopia->delete('/v1/projects/:projectId')
App::delete('/v1/projects/:projectId')
->desc('Delete Project')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -444,7 +445,7 @@ $utopia->delete('/v1/projects/:projectId')
// Webhooks
$utopia->post('/v1/projects/:projectId/webhooks')
App::post('/v1/projects/:projectId/webhooks')
->desc('Create Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -509,7 +510,7 @@ $utopia->post('/v1/projects/:projectId/webhooks')
}
);
$utopia->get('/v1/projects/:projectId/webhooks')
App::get('/v1/projects/:projectId/webhooks')
->desc('List Webhooks')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -542,7 +543,7 @@ $utopia->get('/v1/projects/:projectId/webhooks')
}
);
$utopia->get('/v1/projects/:projectId/webhooks/:webhookId')
App::get('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Get Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -576,7 +577,7 @@ $utopia->get('/v1/projects/:projectId/webhooks/:webhookId')
);
$utopia->put('/v1/projects/:projectId/webhooks/:webhookId')
App::put('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Update Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -632,7 +633,7 @@ $utopia->put('/v1/projects/:projectId/webhooks/:webhookId')
}
);
$utopia->delete('/v1/projects/:projectId/webhooks/:webhookId')
App::delete('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Delete Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -664,7 +665,7 @@ $utopia->delete('/v1/projects/:projectId/webhooks/:webhookId')
// Keys
$utopia->post('/v1/projects/:projectId/keys')
App::post('/v1/projects/:projectId/keys')
->desc('Create Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -711,7 +712,7 @@ $utopia->post('/v1/projects/:projectId/keys')
}
);
$utopia->get('/v1/projects/:projectId/keys')
App::get('/v1/projects/:projectId/keys')
->desc('List Keys')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -730,7 +731,7 @@ $utopia->get('/v1/projects/:projectId/keys')
}
);
$utopia->get('/v1/projects/:projectId/keys/:keyId')
App::get('/v1/projects/:projectId/keys/:keyId')
->desc('Get Key')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -756,7 +757,7 @@ $utopia->get('/v1/projects/:projectId/keys/:keyId')
}
);
$utopia->put('/v1/projects/:projectId/keys/:keyId')
App::put('/v1/projects/:projectId/keys/:keyId')
->desc('Update Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -793,7 +794,7 @@ $utopia->put('/v1/projects/:projectId/keys/:keyId')
}
);
$utopia->delete('/v1/projects/:projectId/keys/:keyId')
App::delete('/v1/projects/:projectId/keys/:keyId')
->desc('Delete Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -825,7 +826,7 @@ $utopia->delete('/v1/projects/:projectId/keys/:keyId')
// Tasks
$utopia->post('/v1/projects/:projectId/tasks')
App::post('/v1/projects/:projectId/tasks')
->desc('Create Task')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -908,7 +909,7 @@ $utopia->post('/v1/projects/:projectId/tasks')
}
);
$utopia->get('/v1/projects/:projectId/tasks')
App::get('/v1/projects/:projectId/tasks')
->desc('List Tasks')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -941,7 +942,7 @@ $utopia->get('/v1/projects/:projectId/tasks')
}
);
$utopia->get('/v1/projects/:projectId/tasks/:taskId')
App::get('/v1/projects/:projectId/tasks/:taskId')
->desc('Get Task')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -974,7 +975,7 @@ $utopia->get('/v1/projects/:projectId/tasks/:taskId')
}
);
$utopia->put('/v1/projects/:projectId/tasks/:taskId')
App::put('/v1/projects/:projectId/tasks/:taskId')
->desc('Update Task')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1045,7 +1046,7 @@ $utopia->put('/v1/projects/:projectId/tasks/:taskId')
}
);
$utopia->delete('/v1/projects/:projectId/tasks/:taskId')
App::delete('/v1/projects/:projectId/tasks/:taskId')
->desc('Delete Task')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1077,7 +1078,7 @@ $utopia->delete('/v1/projects/:projectId/tasks/:taskId')
// Platforms
$utopia->post('/v1/projects/:projectId/platforms')
App::post('/v1/projects/:projectId/platforms')
->desc('Create Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1131,7 +1132,7 @@ $utopia->post('/v1/projects/:projectId/platforms')
}
);
$utopia->get('/v1/projects/:projectId/platforms')
App::get('/v1/projects/:projectId/platforms')
->desc('List Platforms')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -1152,7 +1153,7 @@ $utopia->get('/v1/projects/:projectId/platforms')
}
);
$utopia->get('/v1/projects/:projectId/platforms/:platformId')
App::get('/v1/projects/:projectId/platforms/:platformId')
->desc('Get Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -1178,7 +1179,7 @@ $utopia->get('/v1/projects/:projectId/platforms/:platformId')
}
);
$utopia->put('/v1/projects/:projectId/platforms/:platformId')
App::put('/v1/projects/:projectId/platforms/:platformId')
->desc('Update Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1220,7 +1221,7 @@ $utopia->put('/v1/projects/:projectId/platforms/:platformId')
}
);
$utopia->delete('/v1/projects/:projectId/platforms/:platformId')
App::delete('/v1/projects/:projectId/platforms/:platformId')
->desc('Delete Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1252,7 +1253,7 @@ $utopia->delete('/v1/projects/:projectId/platforms/:platformId')
// Domains
$utopia->post('/v1/projects/:projectId/domains')
App::post('/v1/projects/:projectId/domains')
->desc('Create Domain')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1315,7 +1316,7 @@ $utopia->post('/v1/projects/:projectId/domains')
}
);
$utopia->get('/v1/projects/:projectId/domains')
App::get('/v1/projects/:projectId/domains')
->desc('List Domains')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -1336,7 +1337,7 @@ $utopia->get('/v1/projects/:projectId/domains')
}
);
$utopia->get('/v1/projects/:projectId/domains/:domainId')
App::get('/v1/projects/:projectId/domains/:domainId')
->desc('Get Domain')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@ -1362,7 +1363,7 @@ $utopia->get('/v1/projects/:projectId/domains/:domainId')
}
);
$utopia->patch('/v1/projects/:projectId/domains/:domainId/verification')
App::patch('/v1/projects/:projectId/domains/:domainId/verification')
->desc('Update Domain Verification Status')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@ -1419,7 +1420,7 @@ $utopia->patch('/v1/projects/:projectId/domains/:domainId/verification')
}
);
$utopia->delete('/v1/projects/:projectId/domains/:domainId')
App::delete('/v1/projects/:projectId/domains/:domainId')
->desc('Delete Domain')
->groups(['api', 'projects'])
->label('scope', 'projects.write')

View file

@ -2,6 +2,7 @@
global $utopia, $request, $response, $user, $audit, $usage, $project, $projectDB;
use Utopia\App;
use Utopia\Exception;
use Utopia\Response;
use Utopia\Validator\ArrayList;
@ -129,11 +130,11 @@ $mimes = [
'application/pdf',
];
$utopia->init(function () use ($project) {
App::init(function () use ($project) {
Storage::addDevice('local', new Local(APP_STORAGE_UPLOADS.'/app-'.$project->getId()));
}, 'storage');
$utopia->post('/v1/storage/files')
App::post('/v1/storage/files')
->desc('Create File')
->groups(['api', 'storage'])
->label('scope', 'files.write')
@ -270,7 +271,7 @@ $utopia->post('/v1/storage/files')
}
);
$utopia->get('/v1/storage/files')
App::get('/v1/storage/files')
->desc('List Files')
->groups(['api', 'storage'])
->label('scope', 'files.read')
@ -304,7 +305,7 @@ $utopia->get('/v1/storage/files')
}
);
$utopia->get('/v1/storage/files/:fileId')
App::get('/v1/storage/files/:fileId')
->desc('Get File')
->groups(['api', 'storage'])
->label('scope', 'files.read')
@ -325,7 +326,7 @@ $utopia->get('/v1/storage/files/:fileId')
}
);
$utopia->get('/v1/storage/files/:fileId/preview')
App::get('/v1/storage/files/:fileId/preview')
->desc('Get File Preview')
->groups(['api', 'storage'])
->label('scope', 'files.read')
@ -448,7 +449,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
}
);
$utopia->get('/v1/storage/files/:fileId/download')
App::get('/v1/storage/files/:fileId/download')
->desc('Get File for Download')
->groups(['api', 'storage'])
->label('scope', 'files.read')
@ -502,7 +503,7 @@ $utopia->get('/v1/storage/files/:fileId/download')
}
);
$utopia->get('/v1/storage/files/:fileId/view')
App::get('/v1/storage/files/:fileId/view')
->desc('Get File for View')
->groups(['api', 'storage'])
->label('scope', 'files.read')
@ -573,7 +574,7 @@ $utopia->get('/v1/storage/files/:fileId/view')
}
);
$utopia->put('/v1/storage/files/:fileId')
App::put('/v1/storage/files/:fileId')
->desc('Update File')
->groups(['api', 'storage'])
->label('scope', 'files.write')
@ -619,7 +620,7 @@ $utopia->put('/v1/storage/files/:fileId')
}
);
$utopia->delete('/v1/storage/files/:fileId')
App::delete('/v1/storage/files/:fileId')
->desc('Delete File')
->groups(['api', 'storage'])
->label('scope', 'files.write')
@ -662,7 +663,7 @@ $utopia->delete('/v1/storage/files/:fileId')
}
);
// $utopia->get('/v1/storage/files/:fileId/scan')
// App::get('/v1/storage/files/:fileId/scan')
// ->desc('Scan Storage')
// ->groups(['api', 'storage'])
// ->label('scope', 'god')

View file

@ -2,6 +2,7 @@
global $utopia, $request, $response, $projectDB, $project, $user, $audit, $mail, $mode, $clients;
use Utopia\App;
use Utopia\Exception;
use Utopia\Response;
use Utopia\Config\Config;
@ -20,7 +21,7 @@ use Appwrite\Database\Validator\Authorization;
use Appwrite\Database\Exception\Duplicate;
use Appwrite\Template\Template;
$utopia->post('/v1/teams')
App::post('/v1/teams')
->desc('Create Team')
->groups(['api', 'teams'])
->label('scope', 'teams.write')
@ -84,7 +85,7 @@ $utopia->post('/v1/teams')
}
);
$utopia->get('/v1/teams')
App::get('/v1/teams')
->desc('List Teams')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@ -114,7 +115,7 @@ $utopia->get('/v1/teams')
}
);
$utopia->get('/v1/teams/:teamId')
App::get('/v1/teams/:teamId')
->desc('Get Team')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@ -135,7 +136,7 @@ $utopia->get('/v1/teams/:teamId')
}
);
$utopia->put('/v1/teams/:teamId')
App::put('/v1/teams/:teamId')
->desc('Update Team')
->groups(['api', 'teams'])
->label('scope', 'teams.write')
@ -165,7 +166,7 @@ $utopia->put('/v1/teams/:teamId')
}
);
$utopia->delete('/v1/teams/:teamId')
App::delete('/v1/teams/:teamId')
->desc('Delete Team')
->groups(['api', 'teams'])
->label('scope', 'teams.write')
@ -205,7 +206,7 @@ $utopia->delete('/v1/teams/:teamId')
}
);
$utopia->post('/v1/teams/:teamId/memberships')
App::post('/v1/teams/:teamId/memberships')
->desc('Create Team Membership')
->groups(['api', 'teams'])
->label('scope', 'teams.write')
@ -382,7 +383,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
}
);
$utopia->get('/v1/teams/:teamId/memberships')
App::get('/v1/teams/:teamId/memberships')
->desc('Get Team Memberships')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@ -440,7 +441,7 @@ $utopia->get('/v1/teams/:teamId/memberships')
}
);
$utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
->desc('Update Team Membership Status')
->groups(['api', 'teams'])
->label('scope', 'public')
@ -573,7 +574,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
}
);
$utopia->delete('/v1/teams/:teamId/memberships/:inviteId')
App::delete('/v1/teams/:teamId/memberships/:inviteId')
->desc('Delete Team Membership')
->groups(['api', 'teams'])
->label('scope', 'teams.write')

View file

@ -2,6 +2,7 @@
global $utopia, $response, $projectDB;
use Utopia\App;
use Utopia\Exception;
use Utopia\Response;
use Utopia\Validator\Assoc;
@ -21,7 +22,7 @@ use Appwrite\Database\Validator\UID;
use DeviceDetector\DeviceDetector;
use GeoIp2\Database\Reader;
$utopia->post('/v1/users')
App::post('/v1/users')
->desc('Create User')
->groups(['api', 'users'])
->label('scope', 'users.write')
@ -91,7 +92,7 @@ $utopia->post('/v1/users')
}
);
$utopia->get('/v1/users')
App::get('/v1/users')
->desc('List Users')
->groups(['api', 'users'])
->label('scope', 'users.read')
@ -146,7 +147,7 @@ $utopia->get('/v1/users')
}
);
$utopia->get('/v1/users/:userId')
App::get('/v1/users/:userId')
->desc('Get User')
->groups(['api', 'users'])
->label('scope', 'users.read')
@ -188,7 +189,7 @@ $utopia->get('/v1/users/:userId')
}
);
$utopia->get('/v1/users/:userId/prefs')
App::get('/v1/users/:userId/prefs')
->desc('Get User Preferences')
->groups(['api', 'users'])
->label('scope', 'users.read')
@ -218,7 +219,7 @@ $utopia->get('/v1/users/:userId/prefs')
}
);
$utopia->get('/v1/users/:userId/sessions')
App::get('/v1/users/:userId/sessions')
->desc('Get User Sessions')
->groups(['api', 'users'])
->label('scope', 'users.read')
@ -282,7 +283,7 @@ $utopia->get('/v1/users/:userId/sessions')
}
);
$utopia->get('/v1/users/:userId/logs')
App::get('/v1/users/:userId/logs')
->desc('Get User Logs')
->groups(['api', 'users'])
->label('scope', 'users.read')
@ -363,7 +364,7 @@ $utopia->get('/v1/users/:userId/logs')
}
);
$utopia->patch('/v1/users/:userId/status')
App::patch('/v1/users/:userId/status')
->desc('Update User Status')
->groups(['api', 'users'])
->label('scope', 'users.write')
@ -412,7 +413,7 @@ $utopia->patch('/v1/users/:userId/status')
}
);
$utopia->patch('/v1/users/:userId/prefs')
App::patch('/v1/users/:userId/prefs')
->desc('Update User Preferences')
->groups(['api', 'users'])
->label('scope', 'users.write')
@ -455,7 +456,7 @@ $utopia->patch('/v1/users/:userId/prefs')
);
$utopia->delete('/v1/users/:userId/sessions/:sessionId')
App::delete('/v1/users/:userId/sessions/:sessionId')
->desc('Delete User Session')
->groups(['api', 'users'])
->label('scope', 'users.write')
@ -488,7 +489,7 @@ $utopia->delete('/v1/users/:userId/sessions/:sessionId')
}
);
$utopia->delete('/v1/users/:userId/sessions')
App::delete('/v1/users/:userId/sessions')
->desc('Delete User Sessions')
->groups(['api', 'users'])
->label('scope', 'users.write')

View file

@ -2,16 +2,17 @@
global $utopia, $request, $response;
use Utopia\App;
use Utopia\Response;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;
use Utopia\Validator\ArrayList;
use Utopia\Response;
use Utopia\Validator\Host;
use Appwrite\Storage\Validator\File;
$result = [];
$utopia->get('/v1/mock/tests/foo')
App::get('/v1/mock/tests/foo')
->desc('Mock a get request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'foo')
@ -25,7 +26,7 @@ $utopia->get('/v1/mock/tests/foo')
}
);
$utopia->post('/v1/mock/tests/foo')
App::post('/v1/mock/tests/foo')
->desc('Mock a post request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'foo')
@ -39,7 +40,7 @@ $utopia->post('/v1/mock/tests/foo')
}
);
$utopia->patch('/v1/mock/tests/foo')
App::patch('/v1/mock/tests/foo')
->desc('Mock a patch request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'foo')
@ -53,7 +54,7 @@ $utopia->patch('/v1/mock/tests/foo')
}
);
$utopia->put('/v1/mock/tests/foo')
App::put('/v1/mock/tests/foo')
->desc('Mock a put request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'foo')
@ -67,7 +68,7 @@ $utopia->put('/v1/mock/tests/foo')
}
);
$utopia->delete('/v1/mock/tests/foo')
App::delete('/v1/mock/tests/foo')
->desc('Mock a delete request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'foo')
@ -81,7 +82,7 @@ $utopia->delete('/v1/mock/tests/foo')
}
);
$utopia->get('/v1/mock/tests/bar')
App::get('/v1/mock/tests/bar')
->desc('Mock a get request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'bar')
@ -95,7 +96,7 @@ $utopia->get('/v1/mock/tests/bar')
}
);
$utopia->post('/v1/mock/tests/bar')
App::post('/v1/mock/tests/bar')
->desc('Mock a post request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'bar')
@ -109,7 +110,7 @@ $utopia->post('/v1/mock/tests/bar')
}
);
$utopia->patch('/v1/mock/tests/bar')
App::patch('/v1/mock/tests/bar')
->desc('Mock a patch request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'bar')
@ -123,7 +124,7 @@ $utopia->patch('/v1/mock/tests/bar')
}
);
$utopia->put('/v1/mock/tests/bar')
App::put('/v1/mock/tests/bar')
->desc('Mock a put request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'bar')
@ -137,7 +138,7 @@ $utopia->put('/v1/mock/tests/bar')
}
);
$utopia->delete('/v1/mock/tests/bar')
App::delete('/v1/mock/tests/bar')
->desc('Mock a delete request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'bar')
@ -151,7 +152,7 @@ $utopia->delete('/v1/mock/tests/bar')
}
);
$utopia->post('/v1/mock/tests/general/upload')
App::post('/v1/mock/tests/general/upload')
->desc('Mock a post request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'general')
@ -189,7 +190,7 @@ $utopia->post('/v1/mock/tests/general/upload')
}
);
$utopia->get('/v1/mock/tests/general/redirect')
App::get('/v1/mock/tests/general/redirect')
->desc('Mock a post request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'general')
@ -201,7 +202,7 @@ $utopia->get('/v1/mock/tests/general/redirect')
}
);
$utopia->get('/v1/mock/tests/general/redirected')
App::get('/v1/mock/tests/general/redirected')
->desc('Mock a post request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'general')
@ -212,7 +213,7 @@ $utopia->get('/v1/mock/tests/general/redirected')
}
);
$utopia->get('/v1/mock/tests/general/set-cookie')
App::get('/v1/mock/tests/general/set-cookie')
->desc('Mock a cookie request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'general')
@ -224,7 +225,7 @@ $utopia->get('/v1/mock/tests/general/set-cookie')
}
);
$utopia->get('/v1/mock/tests/general/get-cookie')
App::get('/v1/mock/tests/general/get-cookie')
->desc('Mock a cookie request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'general')
@ -238,7 +239,7 @@ $utopia->get('/v1/mock/tests/general/get-cookie')
}
);
$utopia->get('/v1/mock/tests/general/empty')
App::get('/v1/mock/tests/general/empty')
->desc('Mock a post request for SDK tests')
->label('scope', 'public')
->label('sdk.namespace', 'general')
@ -251,7 +252,7 @@ $utopia->get('/v1/mock/tests/general/empty')
}
);
$utopia->get('/v1/mock/tests/general/oauth2')
App::get('/v1/mock/tests/general/oauth2')
->desc('Mock an OAuth2 login route')
->label('scope', 'public')
->label('docs', false)
@ -265,7 +266,7 @@ $utopia->get('/v1/mock/tests/general/oauth2')
}
);
$utopia->get('/v1/mock/tests/general/oauth2/token')
App::get('/v1/mock/tests/general/oauth2/token')
->desc('Mock an OAuth2 login route')
->label('scope', 'public')
->label('docs', false)
@ -291,7 +292,7 @@ $utopia->get('/v1/mock/tests/general/oauth2/token')
}
);
$utopia->get('/v1/mock/tests/general/oauth2/user')
App::get('/v1/mock/tests/general/oauth2/user')
->desc('Mock an OAuth2 user route')
->label('scope', 'public')
->label('docs', false)
@ -310,7 +311,7 @@ $utopia->get('/v1/mock/tests/general/oauth2/user')
}
);
$utopia->get('/v1/mock/tests/general/oauth2/success')
App::get('/v1/mock/tests/general/oauth2/success')
->label('scope', 'public')
->label('docs', false)
->action(
@ -321,7 +322,7 @@ $utopia->get('/v1/mock/tests/general/oauth2/success')
}
);
$utopia->get('/v1/mock/tests/general/oauth2/failure')
App::get('/v1/mock/tests/general/oauth2/failure')
->label('scope', 'public')
->label('docs', false)
->action(
@ -334,7 +335,7 @@ $utopia->get('/v1/mock/tests/general/oauth2/failure')
}
);
$utopia->shutdown(function() use ($response, $request, &$result, $utopia) {
App::shutdown(function() use ($response, $request, &$result, $utopia) {
$route = $utopia->match($request);
$path = APP_STORAGE_CACHE.'/tests.json';
$tests = (\file_exists($path)) ? \json_decode(\file_get_contents($path), true) : [];

View file

@ -1,12 +1,13 @@
<?php
use Utopia\App;
use Utopia\Exception;
use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit;
global $utopia, $request, $response, $register, $user, $project;
$utopia->init(function () use ($utopia, $request, $response, $register, $user, $project) {
App::init(function () use ($utopia, $request, $response, $register, $user, $project) {
$route = $utopia->match($request);
if (empty($project->getId()) && $route->getLabel('abuse-limit', 0) > 0) { // Abuse limit requires an active project scope

View file

@ -1,11 +1,12 @@
<?php
use Utopia\App;
use Utopia\View;
use Utopia\Config\Config;
$layout = new View(__DIR__.'/../../views/layouts/default.phtml');
$utopia->init(function () use ($utopia, $response, $request, $layout) {
App::init(function () use ($utopia, $response, $request, $layout) {
/* AJAX check */
if (!empty($request->getQuery('version', ''))) {
@ -24,7 +25,7 @@ $utopia->init(function () use ($utopia, $response, $request, $layout) {
['type' => 'developer', 'label' => 'Developer'],
['type' => 'admin', 'label' => 'Admin'],
])
->setParam('env', $utopia->getMode())
->setParam('env', App::getMode())
;
$time = (60 * 60 * 24 * 45); // 45 days cache

View file

@ -2,6 +2,7 @@
global $utopia, $response, $request, $layout, $projectDB;
use Utopia\App;
use Utopia\View;
use Utopia\Config\Config;
use Utopia\Domains\Domain;
@ -10,14 +11,14 @@ use Appwrite\Database\Validator\Authorization;
use Appwrite\Database\Validator\UID;
use Appwrite\Storage\Storage;
$utopia->init(function () use ($layout) {
App::init(function () use ($layout) {
$layout
->setParam('description', 'Appwrite Console allows you to easily manage, monitor, and control your entire backend API and tools.')
->setParam('analytics', 'UA-26264668-5')
;
}, 'console');
$utopia->shutdown(function () use ($response, $request, $layout) {
App::shutdown(function () use ($response, $request, $layout) {
$header = new View(__DIR__.'/../../views/console/comps/header.phtml');
$footer = new View(__DIR__.'/../../views/console/comps/footer.phtml');
@ -34,7 +35,7 @@ $utopia->shutdown(function () use ($response, $request, $layout) {
$response->send($layout->render());
}, 'console');
$utopia->get('/error/:code')
App::get('/error/:code')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'home')
@ -51,7 +52,7 @@ $utopia->get('/error/:code')
->setParam('body', $page);
});
$utopia->get('/console')
App::get('/console')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -67,7 +68,7 @@ $utopia->get('/console')
->setParam('body', $page);
});
$utopia->get('/console/account')
App::get('/console/account')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -85,7 +86,7 @@ $utopia->get('/console/account')
->setParam('body', $page);
});
$utopia->get('/console/notifications')
App::get('/console/notifications')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -97,7 +98,7 @@ $utopia->get('/console/notifications')
->setParam('body', $page);
});
$utopia->get('/console/home')
App::get('/console/home')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -109,7 +110,7 @@ $utopia->get('/console/home')
->setParam('body', $page);
});
$utopia->get('/console/settings')
App::get('/console/settings')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -128,7 +129,7 @@ $utopia->get('/console/settings')
->setParam('body', $page);
});
$utopia->get('/console/webhooks')
App::get('/console/webhooks')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -144,7 +145,7 @@ $utopia->get('/console/webhooks')
->setParam('body', $page);
});
$utopia->get('/console/keys')
App::get('/console/keys')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -159,7 +160,7 @@ $utopia->get('/console/keys')
->setParam('body', $page);
});
$utopia->get('/console/tasks')
App::get('/console/tasks')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -171,7 +172,7 @@ $utopia->get('/console/tasks')
->setParam('body', $page);
});
$utopia->get('/console/database')
App::get('/console/database')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -183,7 +184,7 @@ $utopia->get('/console/database')
->setParam('body', $page);
});
$utopia->get('/console/database/collection')
App::get('/console/database/collection')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -215,7 +216,7 @@ $utopia->get('/console/database/collection')
;
});
$utopia->get('/console/database/document')
App::get('/console/database/document')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -245,7 +246,7 @@ $utopia->get('/console/database/document')
->setParam('body', $page);
});
$utopia->get('/console/storage')
App::get('/console/storage')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -263,7 +264,7 @@ $utopia->get('/console/storage')
->setParam('body', $page);
});
$utopia->get('/console/users')
App::get('/console/users')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -277,7 +278,7 @@ $utopia->get('/console/users')
->setParam('body', $page);
});
$utopia->get('/console/users/user')
App::get('/console/users/user')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')
@ -289,7 +290,7 @@ $utopia->get('/console/users/user')
->setParam('body', $page);
});
$utopia->get('/console/users/teams/team')
App::get('/console/users/teams/team')
->groups(['web', 'console'])
->label('permission', 'public')
->label('scope', 'console')

View file

@ -2,12 +2,13 @@
global $utopia, $response, $request, $layout;
use Utopia\App;
use Utopia\View;
use Utopia\Config\Config;
use Utopia\Validator\WhiteList;
use Utopia\Validator\Range;
$utopia->init(function () use ($layout) {
App::init(function () use ($layout) {
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
@ -25,11 +26,11 @@ $utopia->init(function () use ($layout) {
;
}, 'home');
$utopia->shutdown(function () use ($response, $layout) {
App::shutdown(function () use ($response, $layout) {
$response->send($layout->render());
}, 'home');
$utopia->get('/')
App::get('/')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -39,7 +40,7 @@ $utopia->get('/')
}
);
$utopia->get('/auth/signin')
App::get('/auth/signin')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -51,7 +52,7 @@ $utopia->get('/auth/signin')
->setParam('body', $page);
});
$utopia->get('/auth/signup')
App::get('/auth/signup')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -63,7 +64,7 @@ $utopia->get('/auth/signup')
->setParam('body', $page);
});
$utopia->get('/auth/recovery')
App::get('/auth/recovery')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -75,7 +76,7 @@ $utopia->get('/auth/recovery')
->setParam('body', $page);
});
$utopia->get('/auth/confirm')
App::get('/auth/confirm')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -87,7 +88,7 @@ $utopia->get('/auth/confirm')
->setParam('body', $page);
});
$utopia->get('/auth/join')
App::get('/auth/join')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -99,7 +100,7 @@ $utopia->get('/auth/join')
->setParam('body', $page);
});
$utopia->get('/auth/recovery/reset')
App::get('/auth/recovery/reset')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -112,7 +113,7 @@ $utopia->get('/auth/recovery/reset')
});
$utopia->get('/auth/oauth2/success')
App::get('/auth/oauth2/success')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -127,7 +128,7 @@ $utopia->get('/auth/oauth2/success')
;
});
$utopia->get('/auth/oauth2/failure')
App::get('/auth/oauth2/failure')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -142,7 +143,7 @@ $utopia->get('/auth/oauth2/failure')
;
});
$utopia->get('/error/:code')
App::get('/error/:code')
->groups(['web', 'home'])
->label('permission', 'public')
->label('scope', 'home')
@ -159,7 +160,7 @@ $utopia->get('/error/:code')
->setParam('body', $page);
});
$utopia->get('/open-api-2.json')
App::get('/open-api-2.json')
->groups(['web', 'home'])
->label('scope', 'public')
->label('docs', false)

View file

@ -53,7 +53,7 @@ $request = new Request();
$response = new Response();
$utopia = new App('Asia/Tel_Aviv');
$utopia->setMode($utopia->getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION));
App::setMode(App::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION));
/*
* ENV vars
@ -69,16 +69,16 @@ Config::load('avatar-browsers', __DIR__.'/../app/config/avatars/browsers.php');
Config::load('avatar-credit-cards', __DIR__.'/../app/config/avatars/credit-cards.php');
Config::load('avatar-flags', __DIR__.'/../app/config/avatars/flags.php');
Config::setParam('env', $utopia->getMode());
Config::setParam('env', App::getMode());
Config::setParam('domain', $request->getServer('HTTP_HOST', ''));
Config::setParam('domainVerification', false);
Config::setParam('version', $utopia->getEnv('_APP_VERSION', 'UNKNOWN'));
Config::setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN'));
Config::setParam('protocol', $request->getServer('HTTP_X_FORWARDED_PROTO', $request->getServer('REQUEST_SCHEME', 'https')));
Config::setParam('port', (string) \parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT));
Config::setParam('hostname', \parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', null), PHP_URL_HOST));
Resque::setBackend($utopia->getEnv('_APP_REDIS_HOST', '')
.':'.$utopia->getEnv('_APP_REDIS_PORT', ''));
Resque::setBackend(App::getEnv('_APP_REDIS_HOST', '')
.':'.App::getEnv('_APP_REDIS_PORT', ''));
\define('COOKIE_DOMAIN',
(
@ -95,10 +95,10 @@ Resque::setBackend($utopia->getEnv('_APP_REDIS_HOST', '')
* Registry
*/
$register->set('db', function () use ($utopia) { // Register DB connection
$dbHost = $utopia->getEnv('_APP_DB_HOST', '');
$dbUser = $utopia->getEnv('_APP_DB_USER', '');
$dbPass = $utopia->getEnv('_APP_DB_PASS', '');
$dbScheme = $utopia->getEnv('_APP_DB_SCHEMA', '');
$dbHost = App::getEnv('_APP_DB_HOST', '');
$dbUser = App::getEnv('_APP_DB_USER', '');
$dbPass = App::getEnv('_APP_DB_PASS', '');
$dbScheme = App::getEnv('_APP_DB_SCHEMA', '');
$pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
@ -112,8 +112,8 @@ $register->set('db', function () use ($utopia) { // Register DB connection
return $pdo;
});
$register->set('influxdb', function () use ($utopia) { // Register DB connection
$host = $utopia->getEnv('_APP_INFLUXDB_HOST', '');
$port = $utopia->getEnv('_APP_INFLUXDB_PORT', '');
$host = App::getEnv('_APP_INFLUXDB_HOST', '');
$port = App::getEnv('_APP_INFLUXDB_PORT', '');
if (empty($host) || empty($port)) {
return;
@ -124,8 +124,8 @@ $register->set('influxdb', function () use ($utopia) { // Register DB connection
return $client;
});
$register->set('statsd', function () use ($utopia) { // Register DB connection
$host = $utopia->getEnv('_APP_STATSD_HOST', 'telegraf');
$port = $utopia->getEnv('_APP_STATSD_PORT', 8125);
$host = App::getEnv('_APP_STATSD_HOST', 'telegraf');
$port = App::getEnv('_APP_STATSD_PORT', 8125);
$connection = new \Domnikl\Statsd\Connection\UdpSocket($host, $port);
$statsd = new \Domnikl\Statsd\Client($connection);
@ -135,8 +135,8 @@ $register->set('statsd', function () use ($utopia) { // Register DB connection
$register->set('cache', function () use ($utopia) { // Register cache connection
$redis = new Redis();
$redis->connect($utopia->getEnv('_APP_REDIS_HOST', ''),
$utopia->getEnv('_APP_REDIS_PORT', ''));
$redis->connect(App::getEnv('_APP_REDIS_HOST', ''),
App::getEnv('_APP_REDIS_PORT', ''));
return $redis;
});
@ -145,21 +145,21 @@ $register->set('smtp', function () use ($utopia) {
$mail->isSMTP();
$username = $utopia->getEnv('_APP_SMTP_USERNAME', null);
$password = $utopia->getEnv('_APP_SMTP_PASSWORD', null);
$username = App::getEnv('_APP_SMTP_USERNAME', null);
$password = App::getEnv('_APP_SMTP_PASSWORD', null);
$mail->XMailer = 'Appwrite Mailer';
$mail->Host = $utopia->getEnv('_APP_SMTP_HOST', 'smtp');
$mail->Port = $utopia->getEnv('_APP_SMTP_PORT', 25);
$mail->Host = App::getEnv('_APP_SMTP_HOST', 'smtp');
$mail->Port = App::getEnv('_APP_SMTP_PORT', 25);
$mail->SMTPAuth = (!empty($username) && !empty($password));
$mail->Username = $username;
$mail->Password = $password;
$mail->SMTPSecure = $utopia->getEnv('_APP_SMTP_SECURE', false);
$mail->SMTPSecure = App::getEnv('_APP_SMTP_SECURE', false);
$mail->SMTPAutoTLS = false;
$mail->CharSet = 'UTF-8';
$from = \urldecode($utopia->getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server'));
$email = $utopia->getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM);
$from = \urldecode(App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server'));
$email = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM);
$mail->setFrom($email, $from);
$mail->addReplyTo($email, $from);
@ -249,7 +249,7 @@ if (\in_array($locale, Config::getParam('locales'))) {
'method' => 'GET',
'user_agent' => \sprintf(APP_USERAGENT,
Config::getParam('version'),
$utopia->getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)),
App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)),
'timeout' => 2,
],
]);
@ -329,9 +329,9 @@ if (APP_MODE_ADMIN === $mode) {
// Set project mail
$register->get('smtp')
->setFrom(
$utopia->getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM),
App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM),
($project->getId() === 'console')
? \urldecode($utopia->getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server'))
? \urldecode(App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server'))
: \sprintf(Locale::getText('account.emails.team'), $project->getAttribute('name')
)
);

View file

@ -32,7 +32,7 @@
"appwrite/php-clamav": "1.0.*",
"utopia-php/framework": "0.4.0",
"utopia-php/framework": "0.6.0",
"utopia-php/abuse": "0.2.*",
"utopia-php/audit": "0.3.*",
"utopia-php/cache": "0.2.*",

22
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7f6cbe77fe2e0f8bdff33c37a4d9ca11",
"content-hash": "54f5e7c2291eb22ff442d2c491fa4eca",
"packages": [
{
"name": "appwrite/php-clamav",
@ -1596,16 +1596,16 @@
},
{
"name": "utopia-php/framework",
"version": "0.4.0",
"version": "0.6.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/framework.git",
"reference": "30aeb2aeecf8ea2ab83242efad0f5f9fab8d4be5"
"reference": "5412a080f6fdf99310f20a803a797ae97de8b539"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/30aeb2aeecf8ea2ab83242efad0f5f9fab8d4be5",
"reference": "30aeb2aeecf8ea2ab83242efad0f5f9fab8d4be5",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/5412a080f6fdf99310f20a803a797ae97de8b539",
"reference": "5412a080f6fdf99310f20a803a797ae97de8b539",
"shasum": ""
},
"require": {
@ -1636,7 +1636,7 @@
"php",
"upf"
],
"time": "2020-06-25T18:21:48+00:00"
"time": "2020-06-28T16:54:35+00:00"
},
{
"name": "utopia-php/locale",
@ -1942,16 +1942,16 @@
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "a491d65139e2411c75704e871dd02bdddf5a4bdc"
"reference": "5796d127b0c4ff505b77455148ea9d5269d99758"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a491d65139e2411c75704e871dd02bdddf5a4bdc",
"reference": "a491d65139e2411c75704e871dd02bdddf5a4bdc",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5796d127b0c4ff505b77455148ea9d5269d99758",
"reference": "5796d127b0c4ff505b77455148ea9d5269d99758",
"shasum": ""
},
"require": {
"php": "^7.1"
"php": "^7.1 || ^8.0"
},
"replace": {
"myclabs/deep-copy": "self.version"
@ -1982,7 +1982,7 @@
"object",
"object graph"
],
"time": "2020-03-12T21:49:07+00:00"
"time": "2020-06-28T07:02:41+00:00"
},
{
"name": "phar-io/manifest",