rename App:: to Http::

This commit is contained in:
Damodar Lohani
2023-07-18 01:56:00 +00:00
parent 9ab8c49747
commit 49dfbff4c6
50 changed files with 641 additions and 663 deletions
+40 -40
View File
@@ -46,7 +46,7 @@ use Appwrite\Auth\Validator\PasswordDictionary;
$oauthDefaultSuccess = '/auth/oauth2/success';
$oauthDefaultFailure = '/auth/oauth2/failure';
App::post('/v1/account')
Http::post('/v1/account')
->desc('Create Account')
->groups(['api', 'account', 'auth'])
->label('event', 'users.[userId].create')
@@ -141,7 +141,7 @@ App::post('/v1/account')
->dynamic($user, Response::MODEL_ACCOUNT);
});
App::post('/v1/account/sessions/email')
Http::post('/v1/account/sessions/email')
->alias('/v1/account/sessions')
->desc('Create Email Session')
->groups(['api', 'account', 'auth', 'session'])
@@ -259,7 +259,7 @@ App::post('/v1/account/sessions/email')
$response->dynamic($session, Response::MODEL_SESSION);
});
App::get('/v1/account/sessions/oauth2/:provider')
Http::get('/v1/account/sessions/oauth2/:provider')
->desc('Create OAuth2 Session')
->groups(['api', 'account'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
@@ -294,7 +294,7 @@ App::get('/v1/account/sessions/oauth2/:provider')
$appSecret = $project->getAttribute('authProviders', [])[$provider . 'Secret'] ?? '{}';
if (!empty($appSecret) && isset($appSecret['version'])) {
$key = App::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']);
$key = Http::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']);
$appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag']));
}
@@ -324,7 +324,7 @@ App::get('/v1/account/sessions/oauth2/:provider')
->redirect($oauth2->getLoginURL());
});
App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
Http::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
->groups(['api', 'account'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
@@ -348,7 +348,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
. \http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
});
App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
Http::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
->desc('OAuth2 Callback')
->groups(['api', 'account'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
@@ -373,7 +373,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
. \http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
});
App::get('/v1/account/sessions/oauth2/:provider/redirect')
Http::get('/v1/account/sessions/oauth2/:provider/redirect')
->desc('OAuth2 Redirect')
->groups(['api', 'account', 'session'])
->label('error', __DIR__ . '/../../views/general/error.phtml')
@@ -412,7 +412,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
}
if (!empty($appSecret) && isset($appSecret['version'])) {
$key = App::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']);
$key = Http::getEnv('_APP_OPENSSL_KEY_V' . $appSecret['version']);
$appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag']));
}
@@ -624,7 +624,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
;
});
App::post('/v1/account/sessions/magic-url')
Http::post('/v1/account/sessions/magic-url')
->desc('Create Magic URL session')
->groups(['api', 'account'])
->label('scope', 'public')
@@ -653,7 +653,7 @@ App::post('/v1/account/sessions/magic-url')
->inject('mails')
->action(function (string $userId, string $email, string $url, Request $request, Response $response, Document $project, Database $dbForProject, Locale $locale, Event $events, Mail $mails) {
if (empty(App::getEnv('_APP_SMTP_HOST'))) {
if (empty(Http::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled');
}
@@ -779,7 +779,7 @@ App::post('/v1/account/sessions/magic-url')
;
});
App::put('/v1/account/sessions/magic-url')
Http::put('/v1/account/sessions/magic-url')
->desc('Create Magic URL session (confirmation)')
->groups(['api', 'account', 'session'])
->label('scope', 'public')
@@ -901,7 +901,7 @@ App::put('/v1/account/sessions/magic-url')
$response->dynamic($session, Response::MODEL_SESSION);
});
App::post('/v1/account/sessions/phone')
Http::post('/v1/account/sessions/phone')
->desc('Create Phone session')
->groups(['api', 'account'])
->label('scope', 'public')
@@ -928,7 +928,7 @@ App::post('/v1/account/sessions/phone')
->inject('messaging')
->action(function (string $userId, string $phone, Request $request, Response $response, Document $project, Database $dbForProject, Event $events, EventPhone $messaging) {
if (empty(App::getEnv('_APP_SMS_PROVIDER'))) {
if (empty(Http::getEnv('_APP_SMS_PROVIDER'))) {
throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured');
}
@@ -1021,7 +1021,7 @@ App::post('/v1/account/sessions/phone')
;
});
App::put('/v1/account/sessions/phone')
Http::put('/v1/account/sessions/phone')
->desc('Create Phone Session (confirmation)')
->groups(['api', 'account', 'session'])
->label('scope', 'public')
@@ -1136,7 +1136,7 @@ App::put('/v1/account/sessions/phone')
$response->dynamic($session, Response::MODEL_SESSION);
});
App::post('/v1/account/sessions/anonymous')
Http::post('/v1/account/sessions/anonymous')
->desc('Create Anonymous Session')
->groups(['api', 'account', 'auth', 'session'])
->label('event', 'users.[userId].sessions.[sessionId].create')
@@ -1270,7 +1270,7 @@ App::post('/v1/account/sessions/anonymous')
$response->dynamic($session, Response::MODEL_SESSION);
});
App::post('/v1/account/jwt')
Http::post('/v1/account/jwt')
->desc('Create JWT')
->groups(['api', 'account', 'auth'])
->label('scope', 'account')
@@ -1303,7 +1303,7 @@ App::post('/v1/account/jwt')
throw new Exception(Exception::USER_SESSION_NOT_FOUND);
}
$jwt = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway.
$jwt = new JWT(Http::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway.
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
@@ -1317,7 +1317,7 @@ App::post('/v1/account/jwt')
])]), Response::MODEL_JWT);
});
App::get('/v1/account')
Http::get('/v1/account')
->desc('Get Account')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1338,7 +1338,7 @@ App::get('/v1/account')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::get('/v1/account/prefs')
Http::get('/v1/account/prefs')
->desc('Get Account Preferences')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1361,7 +1361,7 @@ App::get('/v1/account/prefs')
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});
App::get('/v1/account/sessions')
Http::get('/v1/account/sessions')
->desc('List Sessions')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1399,7 +1399,7 @@ App::get('/v1/account/sessions')
]), Response::MODEL_SESSION_LIST);
});
App::get('/v1/account/logs')
Http::get('/v1/account/logs')
->desc('List Logs')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1460,7 +1460,7 @@ App::get('/v1/account/logs')
]), Response::MODEL_LOG_LIST);
});
App::get('/v1/account/sessions/:sessionId')
Http::get('/v1/account/sessions/:sessionId')
->desc('Get Session')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1505,7 +1505,7 @@ App::get('/v1/account/sessions/:sessionId')
throw new Exception(Exception::USER_SESSION_NOT_FOUND);
});
App::patch('/v1/account/name')
Http::patch('/v1/account/name')
->desc('Update Name')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.name')
@@ -1542,7 +1542,7 @@ App::patch('/v1/account/name')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/password')
Http::patch('/v1/account/password')
->desc('Update Password')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.password')
@@ -1603,7 +1603,7 @@ App::patch('/v1/account/password')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/email')
Http::patch('/v1/account/email')
->desc('Update Email')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.email')
@@ -1659,7 +1659,7 @@ App::patch('/v1/account/email')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/phone')
Http::patch('/v1/account/phone')
->desc('Update Phone')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.phone')
@@ -1711,7 +1711,7 @@ App::patch('/v1/account/phone')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/prefs')
Http::patch('/v1/account/prefs')
->desc('Update Preferences')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.prefs')
@@ -1746,7 +1746,7 @@ App::patch('/v1/account/prefs')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::patch('/v1/account/status')
Http::patch('/v1/account/status')
->desc('Update Status')
->groups(['api', 'account'])
->label('event', 'users.[userId].update.status')
@@ -1791,7 +1791,7 @@ App::patch('/v1/account/status')
$response->dynamic($user, Response::MODEL_ACCOUNT);
});
App::delete('/v1/account/sessions/:sessionId')
Http::delete('/v1/account/sessions/:sessionId')
->desc('Delete Session')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1868,7 +1868,7 @@ App::delete('/v1/account/sessions/:sessionId')
throw new Exception(Exception::USER_SESSION_NOT_FOUND);
});
App::patch('/v1/account/sessions/:sessionId')
Http::patch('/v1/account/sessions/:sessionId')
->desc('Update OAuth Session (Refresh Tokens)')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -1954,7 +1954,7 @@ App::patch('/v1/account/sessions/:sessionId')
throw new Exception(Exception::USER_SESSION_NOT_FOUND);
});
App::delete('/v1/account/sessions')
Http::delete('/v1/account/sessions')
->desc('Delete Sessions')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -2016,7 +2016,7 @@ App::delete('/v1/account/sessions')
$response->noContent();
});
App::post('/v1/account/recovery')
Http::post('/v1/account/recovery')
->desc('Create Password Recovery')
->groups(['api', 'account'])
->label('scope', 'public')
@@ -2045,7 +2045,7 @@ App::post('/v1/account/recovery')
->inject('events')
->action(function (string $email, string $url, Request $request, Response $response, Database $dbForProject, Document $project, Locale $locale, Mail $mails, Event $events) {
if (empty(App::getEnv('_APP_SMTP_HOST'))) {
if (empty(Http::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');
}
@@ -2146,7 +2146,7 @@ App::post('/v1/account/recovery')
->dynamic($recovery, Response::MODEL_TOKEN);
});
App::put('/v1/account/recovery')
Http::put('/v1/account/recovery')
->desc('Create Password Recovery (confirmation)')
->groups(['api', 'account'])
->label('scope', 'public')
@@ -2215,7 +2215,7 @@ App::put('/v1/account/recovery')
$response->dynamic($recoveryDocument, Response::MODEL_TOKEN);
});
App::post('/v1/account/verification')
Http::post('/v1/account/verification')
->desc('Create Email Verification')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -2244,7 +2244,7 @@ App::post('/v1/account/verification')
->inject('mails')
->action(function (string $url, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Event $events, Mail $mails) {
if (empty(App::getEnv('_APP_SMTP_HOST'))) {
if (empty(Http::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');
}
@@ -2327,7 +2327,7 @@ App::post('/v1/account/verification')
->dynamic($verification, Response::MODEL_TOKEN);
});
App::put('/v1/account/verification')
Http::put('/v1/account/verification')
->desc('Create Email Verification (confirmation)')
->groups(['api', 'account'])
->label('scope', 'public')
@@ -2387,7 +2387,7 @@ App::put('/v1/account/verification')
$response->dynamic($verificationDocument, Response::MODEL_TOKEN);
});
App::post('/v1/account/verification/phone')
Http::post('/v1/account/verification/phone')
->desc('Create Phone Verification')
->groups(['api', 'account'])
->label('scope', 'account')
@@ -2413,7 +2413,7 @@ App::post('/v1/account/verification/phone')
->inject('messaging')
->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Event $events, EventPhone $messaging) {
if (empty(App::getEnv('_APP_SMS_PROVIDER'))) {
if (empty(Http::getEnv('_APP_SMS_PROVIDER'))) {
throw new Exception(Exception::GENERAL_PHONE_DISABLED);
}
@@ -2473,7 +2473,7 @@ App::post('/v1/account/verification/phone')
->dynamic($verification, Response::MODEL_TOKEN);
});
App::put('/v1/account/verification/phone')
Http::put('/v1/account/verification/phone')
->desc('Create Phone Verification (confirmation)')
->groups(['api', 'account'])
->label('scope', 'public')
+9 -9
View File
@@ -54,7 +54,7 @@ $avatarCallback = function (string $type, string $code, int $width, int $height,
unset($image);
};
App::get('/v1/avatars/credit-cards/:code')
Http::get('/v1/avatars/credit-cards/:code')
->desc('Get Credit Card Icon')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
@@ -74,7 +74,7 @@ App::get('/v1/avatars/credit-cards/:code')
->inject('response')
->action(fn (string $code, int $width, int $height, int $quality, Response $response) => $avatarCallback('credit-cards', $code, $width, $height, $quality, $response));
App::get('/v1/avatars/browsers/:code')
Http::get('/v1/avatars/browsers/:code')
->desc('Get Browser Icon')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
@@ -94,7 +94,7 @@ App::get('/v1/avatars/browsers/:code')
->inject('response')
->action(fn (string $code, int $width, int $height, int $quality, Response $response) => $avatarCallback('browsers', $code, $width, $height, $quality, $response));
App::get('/v1/avatars/flags/:code')
Http::get('/v1/avatars/flags/:code')
->desc('Get Country Flag')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
@@ -114,7 +114,7 @@ App::get('/v1/avatars/flags/:code')
->inject('response')
->action(fn (string $code, int $width, int $height, int $quality, Response $response) => $avatarCallback('flags', $code, $width, $height, $quality, $response));
App::get('/v1/avatars/image')
Http::get('/v1/avatars/image')
->desc('Get Image from URL')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
@@ -165,7 +165,7 @@ App::get('/v1/avatars/image')
unset($image);
});
App::get('/v1/avatars/favicon')
Http::get('/v1/avatars/favicon')
->desc('Get Favicon')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
@@ -201,8 +201,8 @@ App::get('/v1/avatars/favicon')
CURLOPT_URL => $url,
CURLOPT_USERAGENT => \sprintf(
APP_USERAGENT,
App::getEnv('_APP_VERSION', 'UNKNOWN'),
App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
Http::getEnv('_APP_VERSION', 'UNKNOWN'),
Http::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
),
]);
@@ -297,7 +297,7 @@ App::get('/v1/avatars/favicon')
unset($image);
});
App::get('/v1/avatars/qr')
Http::get('/v1/avatars/qr')
->desc('Get QR Code')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
@@ -338,7 +338,7 @@ App::get('/v1/avatars/qr')
;
});
App::get('/v1/avatars/initials')
Http::get('/v1/avatars/initials')
->desc('Get User Initials')
->groups(['api', 'avatars'])
->label('scope', 'avatars.read')
+6 -6
View File
@@ -5,7 +5,7 @@ use Appwrite\Utopia\Response;
use Utopia\Http\Http;
use Utopia\Database\Document;
App::init()
Http::init()
->groups(['console'])
->inject('project')
->action(function (Document $project) {
@@ -15,7 +15,7 @@ App::init()
});
App::get('/v1/console/variables')
Http::get('/v1/console/variables')
->desc('Get Variables')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -30,10 +30,10 @@ App::get('/v1/console/variables')
->action(function (Response $response) {
$variables = new Document([
'_APP_DOMAIN_TARGET' => App::getEnv('_APP_DOMAIN_TARGET'),
'_APP_STORAGE_LIMIT' => +App::getEnv('_APP_STORAGE_LIMIT'),
'_APP_FUNCTIONS_SIZE_LIMIT' => +App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT'),
'_APP_USAGE_STATS' => App::getEnv('_APP_USAGE_STATS'),
'_APP_DOMAIN_TARGET' => Http::getEnv('_APP_DOMAIN_TARGET'),
'_APP_STORAGE_LIMIT' => +Http::getEnv('_APP_STORAGE_LIMIT'),
'_APP_FUNCTIONS_SIZE_LIMIT' => +Http::getEnv('_APP_FUNCTIONS_SIZE_LIMIT'),
'_APP_USAGE_STATS' => Http::getEnv('_APP_USAGE_STATS'),
]);
$response->dynamic($variables, Response::MODEL_CONSOLE_VARIABLES);
+51 -51
View File
@@ -368,7 +368,7 @@ function updateAttribute(
return $attribute;
}
App::post('/v1/databases')
Http::post('/v1/databases')
->desc('Create Database')
->groups(['api', 'database'])
->label('event', 'databases.[databaseId].create')
@@ -445,7 +445,7 @@ App::post('/v1/databases')
->dynamic($database, Response::MODEL_DATABASE);
});
App::get('/v1/databases')
Http::get('/v1/databases')
->desc('List Databases')
->groups(['api', 'database'])
->label('scope', 'databases.read')
@@ -492,7 +492,7 @@ App::get('/v1/databases')
]), Response::MODEL_DATABASE_LIST);
});
App::get('/v1/databases/:databaseId')
Http::get('/v1/databases/:databaseId')
->desc('Get Database')
->groups(['api', 'database'])
->label('scope', 'databases.read')
@@ -518,7 +518,7 @@ App::get('/v1/databases/:databaseId')
$response->dynamic($database, Response::MODEL_DATABASE);
});
App::get('/v1/databases/:databaseId/logs')
Http::get('/v1/databases/:databaseId/logs')
->desc('List Database Logs')
->groups(['api', 'database'])
->label('scope', 'databases.read')
@@ -604,7 +604,7 @@ App::get('/v1/databases/:databaseId/logs')
});
App::put('/v1/databases/:databaseId')
Http::put('/v1/databases/:databaseId')
->desc('Update Database')
->groups(['api', 'database', 'schema'])
->label('scope', 'databases.write')
@@ -649,7 +649,7 @@ App::put('/v1/databases/:databaseId')
$response->dynamic($database, Response::MODEL_DATABASE);
});
App::delete('/v1/databases/:databaseId')
Http::delete('/v1/databases/:databaseId')
->desc('Delete Database')
->groups(['api', 'database', 'schema'])
->label('scope', 'databases.write')
@@ -696,7 +696,7 @@ App::delete('/v1/databases/:databaseId')
$response->noContent();
});
App::post('/v1/databases/:databaseId/collections')
Http::post('/v1/databases/:databaseId/collections')
->alias('/v1/database/collections', ['databaseId' => 'default'])
->desc('Create Collection')
->groups(['api', 'database'])
@@ -766,7 +766,7 @@ App::post('/v1/databases/:databaseId/collections')
->dynamic($collection, Response::MODEL_COLLECTION);
});
App::get('/v1/databases/:databaseId/collections')
Http::get('/v1/databases/:databaseId/collections')
->alias('/v1/database/collections', ['databaseId' => 'default'])
->desc('List Collections')
->groups(['api', 'database'])
@@ -823,7 +823,7 @@ App::get('/v1/databases/:databaseId/collections')
]), Response::MODEL_COLLECTION_LIST);
});
App::get('/v1/databases/:databaseId/collections/:collectionId')
Http::get('/v1/databases/:databaseId/collections/:collectionId')
->alias('/v1/database/collections/:collectionId', ['databaseId' => 'default'])
->desc('Get Collection')
->groups(['api', 'database'])
@@ -859,7 +859,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId')
$response->dynamic($collection, Response::MODEL_COLLECTION);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/logs')
Http::get('/v1/databases/:databaseId/collections/:collectionId/logs')
->alias('/v1/database/collections/:collectionId/logs', ['databaseId' => 'default'])
->desc('List Collection Logs')
->groups(['api', 'database'])
@@ -955,7 +955,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs')
});
App::put('/v1/databases/:databaseId/collections/:collectionId')
Http::put('/v1/databases/:databaseId/collections/:collectionId')
->alias('/v1/database/collections/:collectionId', ['databaseId' => 'default'])
->desc('Update Collection')
->groups(['api', 'database', 'schema'])
@@ -1025,7 +1025,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId')
$response->dynamic($collection, Response::MODEL_COLLECTION);
});
App::delete('/v1/databases/:databaseId/collections/:collectionId')
Http::delete('/v1/databases/:databaseId/collections/:collectionId')
->alias('/v1/database/collections/:collectionId', ['databaseId' => 'default'])
->desc('Delete Collection')
->groups(['api', 'database', 'schema'])
@@ -1081,7 +1081,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId')
$response->noContent();
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string')
->alias('/v1/database/collections/:collectionId/attributes/string', ['databaseId' => 'default'])
->desc('Create String Attribute')
->groups(['api', 'database', 'schema'])
@@ -1131,7 +1131,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string
->dynamic($attribute, Response::MODEL_ATTRIBUTE_STRING);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/email')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/email')
->alias('/v1/database/collections/:collectionId/attributes/email', ['databaseId' => 'default'])
->desc('Create Email Attribute')
->groups(['api', 'database', 'schema'])
@@ -1175,7 +1175,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/email'
->dynamic($attribute, Response::MODEL_ATTRIBUTE_EMAIL);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/enum')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/enum')
->alias('/v1/database/collections/:collectionId/attributes/enum', ['databaseId' => 'default'])
->desc('Create Enum Attribute')
->groups(['api', 'database', 'schema'])
@@ -1235,7 +1235,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/enum')
->dynamic($attribute, Response::MODEL_ATTRIBUTE_ENUM);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/ip')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/ip')
->alias('/v1/database/collections/:collectionId/attributes/ip', ['databaseId' => 'default'])
->desc('Create IP Address Attribute')
->groups(['api', 'database', 'schema'])
@@ -1279,7 +1279,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/ip')
->dynamic($attribute, Response::MODEL_ATTRIBUTE_IP);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/url')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/url')
->alias('/v1/database/collections/:collectionId/attributes/url', ['databaseId' => 'default'])
->desc('Create URL Attribute')
->groups(['api', 'database', 'schema'])
@@ -1323,7 +1323,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/url')
->dynamic($attribute, Response::MODEL_ATTRIBUTE_URL);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/integer')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/integer')
->alias('/v1/database/collections/:collectionId/attributes/integer', ['databaseId' => 'default'])
->desc('Create Integer Attribute')
->groups(['api', 'database', 'schema'])
@@ -1396,7 +1396,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/intege
->dynamic($attribute, Response::MODEL_ATTRIBUTE_INTEGER);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/float')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/float')
->alias('/v1/database/collections/:collectionId/attributes/float', ['databaseId' => 'default'])
->desc('Create Float Attribute')
->groups(['api', 'database', 'schema'])
@@ -1472,7 +1472,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/float'
->dynamic($attribute, Response::MODEL_ATTRIBUTE_FLOAT);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean')
->alias('/v1/database/collections/:collectionId/attributes/boolean', ['databaseId' => 'default'])
->desc('Create Boolean Attribute')
->groups(['api', 'database', 'schema'])
@@ -1515,7 +1515,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/boolea
->dynamic($attribute, Response::MODEL_ATTRIBUTE_BOOLEAN);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/datetime')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/datetime')
->alias('/v1/database/collections/:collectionId/attributes/datetime', ['databaseId' => 'default'])
->desc('Create DateTime Attribute')
->groups(['api', 'database'])
@@ -1559,7 +1559,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/dateti
->dynamic($attribute, Response::MODEL_ATTRIBUTE_DATETIME);
});
App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/relationship')
Http::post('/v1/databases/:databaseId/collections/:collectionId/attributes/relationship')
->alias('/v1/database/collections/:collectionId/attributes/relationship', ['databaseId' => 'default'])
->desc('Create Relationship Attribute')
->groups(['api', 'database'])
@@ -1641,7 +1641,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/relati
->dynamic($attribute, Response::MODEL_ATTRIBUTE_RELATIONSHIP);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/attributes')
Http::get('/v1/databases/:databaseId/collections/:collectionId/attributes')
->alias('/v1/database/collections/:collectionId/attributes', ['databaseId' => 'default'])
->desc('List Attributes')
->groups(['api', 'database'])
@@ -1681,7 +1681,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/attributes')
]), Response::MODEL_ATTRIBUTE_LIST);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
Http::get('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
->alias('/v1/database/collections/:collectionId/attributes/:key', ['databaseId' => 'default'])
->desc('Get Attribute')
->groups(['api', 'database'])
@@ -1758,7 +1758,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
$response->dynamic($attribute, $model);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/string/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/string/:key')
->desc('Update String Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -1798,7 +1798,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/strin
->dynamic($attribute, Response::MODEL_ATTRIBUTE_STRING);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/email/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/email/:key')
->desc('Update Email Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -1839,7 +1839,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/email
->dynamic($attribute, Response::MODEL_ATTRIBUTE_EMAIL);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/enum/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/enum/:key')
->desc('Update Enum Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -1882,7 +1882,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/enum/
->dynamic($attribute, Response::MODEL_ATTRIBUTE_ENUM);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/ip/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/ip/:key')
->desc('Update IP Address Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -1923,7 +1923,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/ip/:k
->dynamic($attribute, Response::MODEL_ATTRIBUTE_IP);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/url/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/url/:key')
->desc('Update URL Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -1964,7 +1964,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/url/:
->dynamic($attribute, Response::MODEL_ATTRIBUTE_URL);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/integer/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/integer/:key')
->desc('Update Integer Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -2015,7 +2015,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/integ
->dynamic($attribute, Response::MODEL_ATTRIBUTE_INTEGER);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/float/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/float/:key')
->desc('Update Float Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -2066,7 +2066,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/float
->dynamic($attribute, Response::MODEL_ATTRIBUTE_FLOAT);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean/:key')
->desc('Update Boolean Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -2106,7 +2106,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/boole
->dynamic($attribute, Response::MODEL_ATTRIBUTE_BOOLEAN);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/datetime/:key')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/datetime/:key')
->desc('Update DateTime Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -2146,7 +2146,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/datet
->dynamic($attribute, Response::MODEL_ATTRIBUTE_DATETIME);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/:key/relationship')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/:key/relationship')
->desc('Update Relationship Attribute')
->groups(['api', 'database', 'schema'])
->label('scope', 'collections.write')
@@ -2201,7 +2201,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/:key/
->dynamic($attribute, Response::MODEL_ATTRIBUTE_RELATIONSHIP);
});
App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
Http::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
->alias('/v1/database/collections/:collectionId/attributes/:key', ['databaseId' => 'default'])
->desc('Delete Attribute')
->groups(['api', 'database', 'schema'])
@@ -2312,7 +2312,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key
$response->noContent();
});
App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
Http::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
->alias('/v1/database/collections/:collectionId/indexes', ['databaseId' => 'default'])
->desc('Create Index')
->groups(['api', 'database'])
@@ -2464,7 +2464,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
->dynamic($index, Response::MODEL_INDEX);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/indexes')
Http::get('/v1/databases/:databaseId/collections/:collectionId/indexes')
->alias('/v1/database/collections/:collectionId/indexes', ['databaseId' => 'default'])
->desc('List Indexes')
->groups(['api', 'database'])
@@ -2503,7 +2503,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes')
]), Response::MODEL_INDEX_LIST);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
Http::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
->alias('/v1/database/collections/:collectionId/indexes/:key', ['databaseId' => 'default'])
->desc('Get Index')
->groups(['api', 'database'])
@@ -2550,7 +2550,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
$response->dynamic($index, Response::MODEL_INDEX);
});
App::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
Http::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
->alias('/v1/database/collections/:collectionId/indexes/:key', ['databaseId' => 'default'])
->desc('Delete Index')
->groups(['api', 'database'])
@@ -2616,7 +2616,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
$response->noContent();
});
App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
Http::post('/v1/databases/:databaseId/collections/:collectionId/documents')
->alias('/v1/database/collections/:collectionId/documents', ['databaseId' => 'default'])
->desc('Create Document')
->groups(['api', 'database'])
@@ -2856,7 +2856,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
->dynamic($document, Response::MODEL_DOCUMENT);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
Http::get('/v1/databases/:databaseId/collections/:collectionId/documents')
->alias('/v1/database/collections/:collectionId/documents', ['databaseId' => 'default'])
->desc('List Documents')
->groups(['api', 'database'])
@@ -2988,7 +2988,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
]), Response::MODEL_DOCUMENT_LIST);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId')
Http::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId')
->alias('/v1/database/collections/:collectionId/documents/:documentId', ['databaseId' => 'default'])
->desc('Get Document')
->groups(['api', 'database'])
@@ -3084,7 +3084,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
$response->dynamic($document, Response::MODEL_DOCUMENT);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId/logs')
Http::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId/logs')
->alias('/v1/database/collections/:collectionId/documents/:documentId/logs', ['databaseId' => 'default'])
->desc('List Document Logs')
->groups(['api', 'database'])
@@ -3185,7 +3185,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
]), Response::MODEL_LOG_LIST);
});
App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId')
Http::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId')
->alias('/v1/database/collections/:collectionId/documents/:documentId', ['databaseId' => 'default'])
->desc('Update Document')
->groups(['api', 'database'])
@@ -3431,7 +3431,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
$response->dynamic($document, Response::MODEL_DOCUMENT);
});
App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId')
Http::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId')
->alias('/v1/database/collections/:collectionId/documents/:documentId', ['databaseId' => 'default'])
->desc('Delete Document')
->groups(['api', 'database'])
@@ -3597,7 +3597,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:docu
$response->noContent();
});
App::get('/v1/databases/usage')
Http::get('/v1/databases/usage')
->desc('Get usage stats for the database')
->groups(['api', 'database', 'usage'])
->label('scope', 'collections.read')
@@ -3613,7 +3613,7 @@ App::get('/v1/databases/usage')
->action(function (string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
@@ -3715,7 +3715,7 @@ App::get('/v1/databases/usage')
$response->dynamic($usage, Response::MODEL_USAGE_DATABASES);
});
App::get('/v1/databases/:databaseId/usage')
Http::get('/v1/databases/:databaseId/usage')
->desc('Get usage stats for the database')
->groups(['api', 'database', 'usage'])
->label('scope', 'collections.read')
@@ -3732,7 +3732,7 @@ App::get('/v1/databases/:databaseId/usage')
->action(function (string $databaseId, string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
@@ -3824,7 +3824,7 @@ App::get('/v1/databases/:databaseId/usage')
$response->dynamic($usage, Response::MODEL_USAGE_DATABASE);
});
App::get('/v1/databases/:databaseId/collections/:collectionId/usage')
Http::get('/v1/databases/:databaseId/collections/:collectionId/usage')
->alias('/v1/database/:collectionId/usage', ['databaseId' => 'default'])
->desc('Get usage stats for a collection')
->groups(['api', 'database', 'usage'])
@@ -3852,7 +3852,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
+29 -29
View File
@@ -45,7 +45,7 @@ use Utopia\Database\Exception\Duplicate as DuplicateException;
include_once __DIR__ . '/../shared/api.php';
App::post('/v1/functions')
Http::post('/v1/functions')
->groups(['api', 'functions'])
->desc('Create Function')
->label('scope', 'functions.write')
@@ -65,7 +65,7 @@ App::post('/v1/functions')
->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.')
->param('events', [], new ArrayList(new ValidatorEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true)
->param('timeout', 15, new Range(1, (int) Http::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true)
->param('enabled', true, new Boolean(), 'Is function enabled?', true)
->inject('response')
->inject('dbForProject')
@@ -112,7 +112,7 @@ App::post('/v1/functions')
->dynamic($function, Response::MODEL_FUNCTION);
});
App::get('/v1/functions')
Http::get('/v1/functions')
->groups(['api', 'functions'])
->desc('List Functions')
->label('scope', 'functions.read')
@@ -158,7 +158,7 @@ App::get('/v1/functions')
]), Response::MODEL_FUNCTION_LIST);
});
App::get('/v1/functions/runtimes')
Http::get('/v1/functions/runtimes')
->groups(['api', 'functions'])
->desc('List runtimes')
->label('scope', 'functions.read')
@@ -185,7 +185,7 @@ App::get('/v1/functions/runtimes')
]), Response::MODEL_RUNTIME_LIST);
});
App::get('/v1/functions/:functionId')
Http::get('/v1/functions/:functionId')
->groups(['api', 'functions'])
->desc('Get Function')
->label('scope', 'functions.read')
@@ -209,7 +209,7 @@ App::get('/v1/functions/:functionId')
$response->dynamic($function, Response::MODEL_FUNCTION);
});
App::get('/v1/functions/:functionId/usage')
Http::get('/v1/functions/:functionId/usage')
->desc('Get Function Usage')
->groups(['api', 'functions', 'usage'])
->label('scope', 'functions.read')
@@ -232,7 +232,7 @@ App::get('/v1/functions/:functionId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
@@ -319,7 +319,7 @@ App::get('/v1/functions/:functionId/usage')
$response->dynamic($usage, Response::MODEL_USAGE_FUNCTION);
});
App::get('/v1/functions/usage')
Http::get('/v1/functions/usage')
->desc('Get Functions Usage')
->groups(['api', 'functions', 'usage'])
->label('scope', 'functions.read')
@@ -335,7 +335,7 @@ App::get('/v1/functions/usage')
->action(function (string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
@@ -422,7 +422,7 @@ App::get('/v1/functions/usage')
$response->dynamic($usage, Response::MODEL_USAGE_FUNCTIONS);
});
App::put('/v1/functions/:functionId')
Http::put('/v1/functions/:functionId')
->groups(['api', 'functions'])
->desc('Update Function')
->label('scope', 'functions.write')
@@ -441,7 +441,7 @@ App::put('/v1/functions/:functionId')
->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true)
->param('events', [], new ArrayList(new ValidatorEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Maximum execution time in seconds.', true)
->param('timeout', 15, new Range(1, (int) Http::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Maximum execution time in seconds.', true)
->param('enabled', true, new Boolean(), 'Is function enabled?', true)
->inject('response')
->inject('dbForProject')
@@ -489,7 +489,7 @@ App::put('/v1/functions/:functionId')
$response->dynamic($function, Response::MODEL_FUNCTION);
});
App::patch('/v1/functions/:functionId/deployments/:deploymentId')
Http::patch('/v1/functions/:functionId/deployments/:deploymentId')
->groups(['api', 'functions'])
->desc('Update Function Deployment')
->label('scope', 'functions.write')
@@ -542,7 +542,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId')
$response->dynamic($function, Response::MODEL_FUNCTION);
});
App::delete('/v1/functions/:functionId')
Http::delete('/v1/functions/:functionId')
->groups(['api', 'functions'])
->desc('Delete Function')
->label('scope', 'functions.write')
@@ -581,7 +581,7 @@ App::delete('/v1/functions/:functionId')
$response->noContent();
});
App::post('/v1/functions/:functionId/deployments')
Http::post('/v1/functions/:functionId/deployments')
->groups(['api', 'functions'])
->desc('Create Deployment')
->label('scope', 'functions.write')
@@ -628,7 +628,7 @@ App::post('/v1/functions/:functionId/deployments')
}
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
$fileSizeValidator = new FileSize(App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', 0));
$fileSizeValidator = new FileSize(Http::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', 0));
$upload = new Upload();
// Make sure we handle a single file and multiple files the same way
@@ -777,7 +777,7 @@ App::post('/v1/functions/:functionId/deployments')
->dynamic($deployment, Response::MODEL_DEPLOYMENT);
});
App::get('/v1/functions/:functionId/deployments')
Http::get('/v1/functions/:functionId/deployments')
->groups(['api', 'functions'])
->desc('List Deployments')
->label('scope', 'functions.read')
@@ -845,7 +845,7 @@ App::get('/v1/functions/:functionId/deployments')
]), Response::MODEL_DEPLOYMENT_LIST);
});
App::get('/v1/functions/:functionId/deployments/:deploymentId')
Http::get('/v1/functions/:functionId/deployments/:deploymentId')
->groups(['api', 'functions'])
->desc('Get Deployment')
->label('scope', 'functions.read')
@@ -886,7 +886,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId')
$response->dynamic($deployment, Response::MODEL_DEPLOYMENT);
});
App::delete('/v1/functions/:functionId/deployments/:deploymentId')
Http::delete('/v1/functions/:functionId/deployments/:deploymentId')
->groups(['api', 'functions'])
->desc('Delete Deployment')
->label('scope', 'functions.write')
@@ -945,7 +945,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId')
$response->noContent();
});
App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
Http::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
->groups(['api', 'functions'])
->desc('Create Build')
->label('scope', 'functions.write')
@@ -1006,7 +1006,7 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
App::post('/v1/functions/:functionId/executions')
Http::post('/v1/functions/:functionId/executions')
->groups(['api', 'functions'])
->desc('Create Execution')
->label('scope', 'execution.write')
@@ -1105,7 +1105,7 @@ App::post('/v1/functions/:functionId/executions')
}
if (!$current->isEmpty()) {
$jwtObj = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway.
$jwtObj = new JWT(Http::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway.
$jwt = $jwtObj->encode([
'userId' => $user->getId(),
'sessionId' => $current->getId(),
@@ -1155,7 +1155,7 @@ App::post('/v1/functions/:functionId/executions')
]);
/** Execute function */
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
$executor = new Executor(Http::getEnv('_APP_EXECUTOR_HOST'));
try {
$executionResponse = $executor->createExecution(
projectId: $project->getId(),
@@ -1209,7 +1209,7 @@ App::post('/v1/functions/:functionId/executions')
->dynamic($execution, Response::MODEL_EXECUTION);
});
App::get('/v1/functions/:functionId/executions')
Http::get('/v1/functions/:functionId/executions')
->groups(['api', 'functions'])
->desc('List Executions')
->label('scope', 'execution.read')
@@ -1282,7 +1282,7 @@ App::get('/v1/functions/:functionId/executions')
]), Response::MODEL_EXECUTION_LIST);
});
App::get('/v1/functions/:functionId/executions/:executionId')
Http::get('/v1/functions/:functionId/executions/:executionId')
->groups(['api', 'functions'])
->desc('Get Execution')
->label('scope', 'execution.read')
@@ -1331,7 +1331,7 @@ App::get('/v1/functions/:functionId/executions/:executionId')
// Variables
App::post('/v1/functions/:functionId/variables')
Http::post('/v1/functions/:functionId/variables')
->desc('Create Variable')
->groups(['api', 'functions'])
->label('scope', 'functions.write')
@@ -1385,7 +1385,7 @@ App::post('/v1/functions/:functionId/variables')
->dynamic($variable, Response::MODEL_VARIABLE);
});
App::get('/v1/functions/:functionId/variables')
Http::get('/v1/functions/:functionId/variables')
->desc('List Variables')
->groups(['api', 'functions'])
->label('scope', 'functions.read')
@@ -1412,7 +1412,7 @@ App::get('/v1/functions/:functionId/variables')
]), Response::MODEL_VARIABLE_LIST);
});
App::get('/v1/functions/:functionId/variables/:variableId')
Http::get('/v1/functions/:functionId/variables/:variableId')
->desc('Get Variable')
->groups(['api', 'functions'])
->label('scope', 'functions.read')
@@ -1446,7 +1446,7 @@ App::get('/v1/functions/:functionId/variables/:variableId')
$response->dynamic($variable, Response::MODEL_VARIABLE);
});
App::put('/v1/functions/:functionId/variables/:variableId')
Http::put('/v1/functions/:functionId/variables/:variableId')
->desc('Update Variable')
->groups(['api', 'functions'])
->label('scope', 'functions.write')
@@ -1499,7 +1499,7 @@ App::put('/v1/functions/:functionId/variables/:variableId')
$response->dynamic($variable, Response::MODEL_VARIABLE);
});
App::delete('/v1/functions/:functionId/variables/:variableId')
Http::delete('/v1/functions/:functionId/variables/:variableId')
->desc('Delete Variable')
->groups(['api', 'functions'])
->label('scope', 'functions.write')
+9 -9
View File
@@ -17,7 +17,7 @@ use Utopia\Database\Document;
use Utopia\Http\Validator\JSON;
use Utopia\Http\Validator\Text;
App::get('/v1/graphql')
Http::get('/v1/graphql')
->desc('GraphQL Endpoint')
->groups(['graphql'])
->label('scope', 'graphql')
@@ -57,7 +57,7 @@ App::get('/v1/graphql')
->json($output);
});
App::post('/v1/graphql/mutation')
Http::post('/v1/graphql/mutation')
->desc('GraphQL Endpoint')
->groups(['graphql'])
->label('scope', 'graphql')
@@ -102,7 +102,7 @@ App::post('/v1/graphql/mutation')
->json($output);
});
App::post('/v1/graphql')
Http::post('/v1/graphql')
->desc('GraphQL Endpoint')
->groups(['graphql'])
->label('scope', 'graphql')
@@ -161,9 +161,9 @@ function execute(
Adapter $promiseAdapter,
array $query
): array {
$maxBatchSize = App::getEnv('_APP_GRAPHQL_MAX_BATCH_SIZE', 10);
$maxComplexity = App::getEnv('_APP_GRAPHQL_MAX_COMPLEXITY', 250);
$maxDepth = App::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3);
$maxBatchSize = Http::getEnv('_APP_GRAPHQL_MAX_BATCH_SIZE', 10);
$maxComplexity = Http::getEnv('_APP_GRAPHQL_MAX_COMPLEXITY', 250);
$maxDepth = Http::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3);
if (!empty($query) && !isset($query[0])) {
$query = [$query];
@@ -183,12 +183,12 @@ function execute(
$flags = DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE;
$validations = GraphQL::getStandardValidationRules();
if (App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') {
if (Http::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') {
$validations[] = new DisableIntrospection();
$validations[] = new QueryComplexity($maxComplexity);
$validations[] = new QueryDepth($maxDepth);
}
if (App::getMode() === App::MODE_TYPE_PRODUCTION) {
if (Http::getMode() === Http::MODE_TYPE_PRODUCTION) {
$flags = DebugFlag::NONE;
}
@@ -289,7 +289,7 @@ function processResult($result, $debugFlags): array
);
}
App::shutdown()
Http::shutdown()
->groups(['schema'])
->inject('project')
->action(function (Document $project) {
+15 -15
View File
@@ -11,7 +11,7 @@ use Utopia\Storage\Device;
use Utopia\Storage\Device\Local;
use Utopia\Storage\Storage;
App::get('/v1/health')
Http::get('/v1/health')
->desc('Get HTTP')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -33,7 +33,7 @@ App::get('/v1/health')
$response->dynamic(new Document($output), Response::MODEL_HEALTH_STATUS);
});
App::get('/v1/health/version')
Http::get('/v1/health/version')
->desc('Get Version')
->groups(['api', 'health'])
->label('scope', 'public')
@@ -46,7 +46,7 @@ App::get('/v1/health/version')
$response->dynamic(new Document([ 'version' => APP_VERSION_STABLE ]), Response::MODEL_HEALTH_VERSION);
});
App::get('/v1/health/db')
Http::get('/v1/health/db')
->desc('Get DB')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -84,7 +84,7 @@ App::get('/v1/health/db')
$response->dynamic(new Document($output), Response::MODEL_HEALTH_STATUS);
});
App::get('/v1/health/cache')
Http::get('/v1/health/cache')
->desc('Get Cache')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -115,7 +115,7 @@ App::get('/v1/health/cache')
$response->dynamic(new Document($output), Response::MODEL_HEALTH_STATUS);
});
App::get('/v1/health/time')
Http::get('/v1/health/time')
->desc('Get Time')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -172,7 +172,7 @@ App::get('/v1/health/time')
$response->dynamic(new Document($output), Response::MODEL_HEALTH_TIME);
});
App::get('/v1/health/queue/webhooks')
Http::get('/v1/health/queue/webhooks')
->desc('Get Webhooks Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -189,7 +189,7 @@ App::get('/v1/health/queue/webhooks')
$response->dynamic(new Document([ 'size' => Resque::size(Event::WEBHOOK_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE);
}, ['response']);
App::get('/v1/health/queue/logs')
Http::get('/v1/health/queue/logs')
->desc('Get Logs Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -206,7 +206,7 @@ App::get('/v1/health/queue/logs')
$response->dynamic(new Document([ 'size' => Resque::size(Event::AUDITS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE);
}, ['response']);
App::get('/v1/health/queue/certificates')
Http::get('/v1/health/queue/certificates')
->desc('Get Certificates Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -223,7 +223,7 @@ App::get('/v1/health/queue/certificates')
$response->dynamic(new Document([ 'size' => Resque::size(Event::CERTIFICATES_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE);
}, ['response']);
App::get('/v1/health/queue/functions')
Http::get('/v1/health/queue/functions')
->desc('Get Functions Queue')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -240,7 +240,7 @@ App::get('/v1/health/queue/functions')
$response->dynamic(new Document([ 'size' => Resque::size(Event::FUNCTIONS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE);
}, ['response']);
App::get('/v1/health/storage/local')
Http::get('/v1/health/storage/local')
->desc('Get Local Storage')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -283,7 +283,7 @@ App::get('/v1/health/storage/local')
$response->dynamic(new Document($output), Response::MODEL_HEALTH_STATUS);
});
App::get('/v1/health/anti-virus')
Http::get('/v1/health/anti-virus')
->desc('Get Antivirus')
->groups(['api', 'health'])
->label('scope', 'health.read')
@@ -302,13 +302,13 @@ App::get('/v1/health/anti-virus')
'version' => ''
];
if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled
if (Http::getEnv('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled
$output['status'] = 'disabled';
$output['version'] = '';
} else {
$antivirus = new Network(
App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'),
(int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)
Http::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'),
(int) Http::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)
);
try {
@@ -322,7 +322,7 @@ App::get('/v1/health/anti-virus')
$response->dynamic(new Document($output), Response::MODEL_HEALTH_ANTIVIRUS);
});
App::get('/v1/health/stats') // Currently only used internally
Http::get('/v1/health/stats') // Currently only used internally
->desc('Get System Stats')
->groups(['api', 'health'])
->label('scope', 'root')
+7 -7
View File
@@ -8,7 +8,7 @@ use Utopia\Config\Config;
use Utopia\Database\Document;
use Utopia\Locale\Locale;
App::get('/v1/locale')
Http::get('/v1/locale')
->desc('Get User Locale')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@@ -68,7 +68,7 @@ App::get('/v1/locale')
$response->dynamic(new Document($output), Response::MODEL_LOCALE);
});
App::get('/v1/locale/countries')
Http::get('/v1/locale/countries')
->desc('List Countries')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@@ -101,7 +101,7 @@ App::get('/v1/locale/countries')
$response->dynamic(new Document(['countries' => $output, 'total' => \count($output)]), Response::MODEL_COUNTRY_LIST);
});
App::get('/v1/locale/countries/eu')
Http::get('/v1/locale/countries/eu')
->desc('List EU Countries')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@@ -136,7 +136,7 @@ App::get('/v1/locale/countries/eu')
$response->dynamic(new Document(['countries' => $output, 'total' => \count($output)]), Response::MODEL_COUNTRY_LIST);
});
App::get('/v1/locale/countries/phones')
Http::get('/v1/locale/countries/phones')
->desc('List Countries Phone Codes')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@@ -170,7 +170,7 @@ App::get('/v1/locale/countries/phones')
$response->dynamic(new Document(['phones' => $output, 'total' => \count($output)]), Response::MODEL_PHONE_LIST);
});
App::get('/v1/locale/continents')
Http::get('/v1/locale/continents')
->desc('List Continents')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@@ -202,7 +202,7 @@ App::get('/v1/locale/continents')
$response->dynamic(new Document(['continents' => $output, 'total' => \count($output)]), Response::MODEL_CONTINENT_LIST);
});
App::get('/v1/locale/currencies')
Http::get('/v1/locale/currencies')
->desc('List Currencies')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
@@ -225,7 +225,7 @@ App::get('/v1/locale/currencies')
});
App::get('/v1/locale/languages')
Http::get('/v1/locale/languages')
->desc('List Languages')
->groups(['api', 'locale'])
->label('scope', 'locale.read')
+40 -40
View File
@@ -37,7 +37,7 @@ use Utopia\Http\Validator\Range;
use Utopia\Http\Validator\Text;
use Utopia\Http\Validator\WhiteList;
App::init()
Http::init()
->groups(['projects'])
->inject('project')
->action(function (Document $project) {
@@ -46,7 +46,7 @@ App::init()
}
});
App::post('/v1/projects')
Http::post('/v1/projects')
->desc('Create Project')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -59,7 +59,7 @@ App::post('/v1/projects')
->param('projectId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('name', null, new Text(128), 'Project name. Max length: 128 chars.')
->param('teamId', '', new UID(), 'Team unique ID.')
->param('region', App::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn($config) => !$config['disabled']))), 'Project Region.', true)
->param('region', Http::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn($config) => !$config['disabled']))), 'Project Region.', true)
->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true)
->param('logo', '', new Text(1024), 'Project logo.', true)
->param('url', '', new URL(), 'Project URL.', true)
@@ -180,7 +180,7 @@ App::post('/v1/projects')
->dynamic($project, Response::MODEL_PROJECT);
});
App::get('/v1/projects')
Http::get('/v1/projects')
->desc('List Projects')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -225,7 +225,7 @@ App::get('/v1/projects')
]), Response::MODEL_PROJECT_LIST);
});
App::get('/v1/projects/:projectId')
Http::get('/v1/projects/:projectId')
->desc('Get Project')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -249,7 +249,7 @@ App::get('/v1/projects/:projectId')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::get('/v1/projects/:projectId/usage')
Http::get('/v1/projects/:projectId/usage')
->desc('Get usage stats for a project')
->groups(['api', 'projects', 'usage'])
->label('scope', 'projects.read')
@@ -274,7 +274,7 @@ App::get('/v1/projects/:projectId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
@@ -363,7 +363,7 @@ App::get('/v1/projects/:projectId/usage')
$response->dynamic($usage, Response::MODEL_USAGE_PROJECT);
});
App::patch('/v1/projects/:projectId')
Http::patch('/v1/projects/:projectId')
->desc('Update Project')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -410,7 +410,7 @@ App::patch('/v1/projects/:projectId')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/service')
Http::patch('/v1/projects/:projectId/service')
->desc('Update service status')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -441,7 +441,7 @@ App::patch('/v1/projects/:projectId/service')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/oauth2')
Http::patch('/v1/projects/:projectId/oauth2')
->desc('Update Project OAuth2')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -485,7 +485,7 @@ App::patch('/v1/projects/:projectId/oauth2')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/auth/limit')
Http::patch('/v1/projects/:projectId/auth/limit')
->desc('Update Project users limit')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -516,7 +516,7 @@ App::patch('/v1/projects/:projectId/auth/limit')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/auth/duration')
Http::patch('/v1/projects/:projectId/auth/duration')
->desc('Update Project Authentication Duration')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -547,7 +547,7 @@ App::patch('/v1/projects/:projectId/auth/duration')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/auth/:method')
Http::patch('/v1/projects/:projectId/auth/:method')
->desc('Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project.')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -581,7 +581,7 @@ App::patch('/v1/projects/:projectId/auth/:method')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/auth/password-history')
Http::patch('/v1/projects/:projectId/auth/password-history')
->desc('Update authentication password history. Use this endpoint to set the number of password history to save and 0 to disable password history.')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -612,7 +612,7 @@ App::patch('/v1/projects/:projectId/auth/password-history')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/auth/password-dictionary')
Http::patch('/v1/projects/:projectId/auth/password-dictionary')
->desc('Update authentication password disctionary status. Use this endpoint to enable or disable the dicitonary check for user password')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -643,7 +643,7 @@ App::patch('/v1/projects/:projectId/auth/password-dictionary')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::patch('/v1/projects/:projectId/auth/max-sessions')
Http::patch('/v1/projects/:projectId/auth/max-sessions')
->desc('Update Project user sessions limit')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -674,7 +674,7 @@ App::patch('/v1/projects/:projectId/auth/max-sessions')
$response->dynamic($project, Response::MODEL_PROJECT);
});
App::delete('/v1/projects/:projectId')
Http::delete('/v1/projects/:projectId')
->desc('Delete Project')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -709,7 +709,7 @@ App::delete('/v1/projects/:projectId')
// Webhooks
App::post('/v1/projects/:projectId/webhooks')
Http::post('/v1/projects/:projectId/webhooks')
->desc('Create Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -765,7 +765,7 @@ App::post('/v1/projects/:projectId/webhooks')
->dynamic($webhook, Response::MODEL_WEBHOOK);
});
App::get('/v1/projects/:projectId/webhooks')
Http::get('/v1/projects/:projectId/webhooks')
->desc('List Webhooks')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -797,7 +797,7 @@ App::get('/v1/projects/:projectId/webhooks')
]), Response::MODEL_WEBHOOK_LIST);
});
App::get('/v1/projects/:projectId/webhooks/:webhookId')
Http::get('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Get Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -831,7 +831,7 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId')
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
});
App::put('/v1/projects/:projectId/webhooks/:webhookId')
Http::put('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Update Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -885,7 +885,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId')
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
});
App::patch('/v1/projects/:projectId/webhooks/:webhookId/signature')
Http::patch('/v1/projects/:projectId/webhooks/:webhookId/signature')
->desc('Update Webhook Signature Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -924,7 +924,7 @@ App::patch('/v1/projects/:projectId/webhooks/:webhookId/signature')
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
});
App::delete('/v1/projects/:projectId/webhooks/:webhookId')
Http::delete('/v1/projects/:projectId/webhooks/:webhookId')
->desc('Delete Webhook')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -963,7 +963,7 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId')
// Keys
App::post('/v1/projects/:projectId/keys')
Http::post('/v1/projects/:projectId/keys')
->desc('Create Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1013,7 +1013,7 @@ App::post('/v1/projects/:projectId/keys')
->dynamic($key, Response::MODEL_KEY);
});
App::get('/v1/projects/:projectId/keys')
Http::get('/v1/projects/:projectId/keys')
->desc('List Keys')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -1045,7 +1045,7 @@ App::get('/v1/projects/:projectId/keys')
]), Response::MODEL_KEY_LIST);
});
App::get('/v1/projects/:projectId/keys/:keyId')
Http::get('/v1/projects/:projectId/keys/:keyId')
->desc('Get Key')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -1079,7 +1079,7 @@ App::get('/v1/projects/:projectId/keys/:keyId')
$response->dynamic($key, Response::MODEL_KEY);
});
App::put('/v1/projects/:projectId/keys/:keyId')
Http::put('/v1/projects/:projectId/keys/:keyId')
->desc('Update Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1126,7 +1126,7 @@ App::put('/v1/projects/:projectId/keys/:keyId')
$response->dynamic($key, Response::MODEL_KEY);
});
App::delete('/v1/projects/:projectId/keys/:keyId')
Http::delete('/v1/projects/:projectId/keys/:keyId')
->desc('Delete Key')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1165,7 +1165,7 @@ App::delete('/v1/projects/:projectId/keys/:keyId')
// Platforms
App::post('/v1/projects/:projectId/platforms')
Http::post('/v1/projects/:projectId/platforms')
->desc('Create Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1215,7 +1215,7 @@ App::post('/v1/projects/:projectId/platforms')
->dynamic($platform, Response::MODEL_PLATFORM);
});
App::get('/v1/projects/:projectId/platforms')
Http::get('/v1/projects/:projectId/platforms')
->desc('List Platforms')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -1247,7 +1247,7 @@ App::get('/v1/projects/:projectId/platforms')
]), Response::MODEL_PLATFORM_LIST);
});
App::get('/v1/projects/:projectId/platforms/:platformId')
Http::get('/v1/projects/:projectId/platforms/:platformId')
->desc('Get Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -1281,7 +1281,7 @@ App::get('/v1/projects/:projectId/platforms/:platformId')
$response->dynamic($platform, Response::MODEL_PLATFORM);
});
App::put('/v1/projects/:projectId/platforms/:platformId')
Http::put('/v1/projects/:projectId/platforms/:platformId')
->desc('Update Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1329,7 +1329,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId')
$response->dynamic($platform, Response::MODEL_PLATFORM);
});
App::delete('/v1/projects/:projectId/platforms/:platformId')
Http::delete('/v1/projects/:projectId/platforms/:platformId')
->desc('Delete Platform')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1368,7 +1368,7 @@ App::delete('/v1/projects/:projectId/platforms/:platformId')
// Domains
App::post('/v1/projects/:projectId/domains')
Http::post('/v1/projects/:projectId/domains')
->desc('Create Domain')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1399,7 +1399,7 @@ App::post('/v1/projects/:projectId/domains')
throw new Exception(Exception::DOMAIN_ALREADY_EXISTS);
}
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
$target = new Domain(Http::getEnv('_APP_DOMAIN_TARGET', ''));
if (!$target->isKnown() || $target->isTest()) {
throw new Exception(Exception::DOMAIN_TARGET_INVALID, 'Unreachable CNAME target (' . $target->get() . '). Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
@@ -1433,7 +1433,7 @@ App::post('/v1/projects/:projectId/domains')
->dynamic($domain, Response::MODEL_DOMAIN);
});
App::get('/v1/projects/:projectId/domains')
Http::get('/v1/projects/:projectId/domains')
->desc('List Domains')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -1465,7 +1465,7 @@ App::get('/v1/projects/:projectId/domains')
]), Response::MODEL_DOMAIN_LIST);
});
App::get('/v1/projects/:projectId/domains/:domainId')
Http::get('/v1/projects/:projectId/domains/:domainId')
->desc('Get Domain')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
@@ -1499,7 +1499,7 @@ App::get('/v1/projects/:projectId/domains/:domainId')
$response->dynamic($domain, Response::MODEL_DOMAIN);
});
App::patch('/v1/projects/:projectId/domains/:domainId/verification')
Http::patch('/v1/projects/:projectId/domains/:domainId/verification')
->desc('Update Domain Verification Status')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
@@ -1530,7 +1530,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification')
throw new Exception(Exception::DOMAIN_NOT_FOUND);
}
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
$target = new Domain(Http::getEnv('_APP_DOMAIN_TARGET', ''));
if (!$target->isKnown() || $target->isTest()) {
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.');
@@ -1559,7 +1559,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification')
$response->dynamic($domain, Response::MODEL_DOMAIN);
});
App::delete('/v1/projects/:projectId/domains/:domainId')
Http::delete('/v1/projects/:projectId/domains/:domainId')
->desc('Delete Domain')
->groups(['api', 'projects'])
->label('scope', 'projects.write')
+29 -29
View File
@@ -43,7 +43,7 @@ use Utopia\Http\Validator\Text;
use Utopia\Http\Validator\WhiteList;
use Utopia\Swoole\Request;
App::post('/v1/storage/buckets')
Http::post('/v1/storage/buckets')
->desc('Create bucket')
->groups(['api', 'storage'])
->label('scope', 'buckets.write')
@@ -63,7 +63,7 @@ App::post('/v1/storage/buckets')
->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).', true)
->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).', true)
->param('enabled', true, new Boolean(true), 'Is bucket enabled?', true)
->param('maximumFileSize', (int) App::getEnv('_APP_STORAGE_LIMIT', 0), new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](/docs/environment-variables#storage)', true)
->param('maximumFileSize', (int) Http::getEnv('_APP_STORAGE_LIMIT', 0), new Range(1, (int) Http::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(Http::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](/docs/environment-variables#storage)', true)
->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true)
->param('compression', COMPRESSION_TYPE_NONE, new WhiteList([COMPRESSION_TYPE_NONE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . COMPRESSION_TYPE_NONE . ', [' . COMPRESSION_TYPE_GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . COMPRESSION_TYPE_ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true)
->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true)
@@ -142,7 +142,7 @@ App::post('/v1/storage/buckets')
->dynamic($bucket, Response::MODEL_BUCKET);
});
App::get('/v1/storage/buckets')
Http::get('/v1/storage/buckets')
->desc('List buckets')
->groups(['api', 'storage'])
->label('scope', 'buckets.read')
@@ -189,7 +189,7 @@ App::get('/v1/storage/buckets')
]), Response::MODEL_BUCKET_LIST);
});
App::get('/v1/storage/buckets/:bucketId')
Http::get('/v1/storage/buckets/:bucketId')
->desc('Get Bucket')
->groups(['api', 'storage'])
->label('scope', 'buckets.read')
@@ -215,7 +215,7 @@ App::get('/v1/storage/buckets/:bucketId')
$response->dynamic($bucket, Response::MODEL_BUCKET);
});
App::put('/v1/storage/buckets/:bucketId')
Http::put('/v1/storage/buckets/:bucketId')
->desc('Update Bucket')
->groups(['api', 'storage'])
->label('scope', 'buckets.write')
@@ -235,7 +235,7 @@ App::put('/v1/storage/buckets/:bucketId')
->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).', true)
->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).', true)
->param('enabled', true, new Boolean(true), 'Is bucket enabled?', true)
->param('maximumFileSize', null, new Range(1, (int) App::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human((int)App::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](/docs/environment-variables#storage)', true)
->param('maximumFileSize', null, new Range(1, (int) Http::getEnv('_APP_STORAGE_LIMIT', 0)), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human((int)Http::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](/docs/environment-variables#storage)', true)
->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true)
->param('compression', COMPRESSION_TYPE_NONE, new WhiteList([COMPRESSION_TYPE_NONE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZSTD]), 'Compression algorithm choosen for compression. Can be one of ' . COMPRESSION_TYPE_NONE . ', [' . COMPRESSION_TYPE_GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . COMPRESSION_TYPE_ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true)
->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true)
@@ -251,7 +251,7 @@ App::put('/v1/storage/buckets/:bucketId')
}
$permissions ??= $bucket->getPermissions();
$maximumFileSize ??= $bucket->getAttribute('maximumFileSize', (int) App::getEnv('_APP_STORAGE_LIMIT', 0));
$maximumFileSize ??= $bucket->getAttribute('maximumFileSize', (int) Http::getEnv('_APP_STORAGE_LIMIT', 0));
$allowedFileExtensions ??= $bucket->getAttribute('allowedFileExtensions', []);
$enabled ??= $bucket->getAttribute('enabled', true);
$encryption ??= $bucket->getAttribute('encryption', true);
@@ -283,7 +283,7 @@ App::put('/v1/storage/buckets/:bucketId')
$response->dynamic($bucket, Response::MODEL_BUCKET);
});
App::delete('/v1/storage/buckets/:bucketId')
Http::delete('/v1/storage/buckets/:bucketId')
->desc('Delete Bucket')
->groups(['api', 'storage'])
->label('scope', 'buckets.write')
@@ -325,7 +325,7 @@ App::delete('/v1/storage/buckets/:bucketId')
$response->noContent();
});
App::post('/v1/storage/buckets/:bucketId/files')
Http::post('/v1/storage/buckets/:bucketId/files')
->alias('/v1/storage/files', ['bucketId' => 'default'])
->desc('Create File')
->groups(['api', 'storage'])
@@ -414,7 +414,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
}
$maximumFileSize = $bucket->getAttribute('maximumFileSize', 0);
if ($maximumFileSize > (int) App::getEnv('_APP_STORAGE_LIMIT', 0)) {
if ($maximumFileSize > (int) Http::getEnv('_APP_STORAGE_LIMIT', 0)) {
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Maximum bucket file size is larger than _APP_STORAGE_LIMIT');
}
@@ -502,10 +502,10 @@ App::post('/v1/storage/buckets/:bucketId/files')
}
if ($chunksUploaded === $chunks) {
if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled' && $bucket->getAttribute('antivirus', true) && $fileSize <= APP_LIMIT_ANTIVIRUS && strtolower(App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) === Storage::DEVICE_LOCAL) {
if (Http::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled' && $bucket->getAttribute('antivirus', true) && $fileSize <= APP_LIMIT_ANTIVIRUS && strtolower(Http::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) === Storage::DEVICE_LOCAL) {
$antivirus = new Network(
App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'),
(int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)
Http::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'),
(int) Http::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)
);
if (!$antivirus->fileScan($path)) {
@@ -537,7 +537,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
if (empty($data)) {
$data = $deviceFiles->read($path);
}
$key = App::getEnv('_APP_OPENSSL_KEY_V1');
$key = Http::getEnv('_APP_OPENSSL_KEY_V1');
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
$data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag);
}
@@ -666,7 +666,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
->dynamic($file, Response::MODEL_FILE);
});
App::get('/v1/storage/buckets/:bucketId/files')
Http::get('/v1/storage/buckets/:bucketId/files')
->alias('/v1/storage/files', ['bucketId' => 'default'])
->desc('List Files')
->groups(['api', 'storage'])
@@ -743,7 +743,7 @@ App::get('/v1/storage/buckets/:bucketId/files')
]), Response::MODEL_FILE_LIST);
});
App::get('/v1/storage/buckets/:bucketId/files/:fileId')
Http::get('/v1/storage/buckets/:bucketId/files/:fileId')
->alias('/v1/storage/files/:fileId', ['bucketId' => 'default'])
->desc('Get File')
->groups(['api', 'storage'])
@@ -790,7 +790,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId')
$response->dynamic($file, Response::MODEL_FILE);
});
App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
Http::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
->alias('/v1/storage/files/:fileId/preview', ['bucketId' => 'default'])
->desc('Get File Preview')
->groups(['api', 'storage'])
@@ -869,7 +869,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
$algorithm = $file->getAttribute('algorithm', 'none');
$cipher = $file->getAttribute('openSSLCipher');
$mime = $file->getAttribute('mimeType');
if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > (int) App::getEnv('_APP_STORAGE_PREVIEW_LIMIT', 20000000)) {
if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > (int) Http::getEnv('_APP_STORAGE_PREVIEW_LIMIT', 20000000)) {
if (!\in_array($mime, $inputs)) {
$path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default'];
} else {
@@ -901,7 +901,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
$source = OpenSSL::decrypt(
$source,
$file->getAttribute('openSSLCipher'),
App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')),
Http::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')),
0,
\hex2bin($file->getAttribute('openSSLIV')),
\hex2bin($file->getAttribute('openSSLTag'))
@@ -956,7 +956,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
unset($image);
});
App::get('/v1/storage/buckets/:bucketId/files/:fileId/download')
Http::get('/v1/storage/buckets/:bucketId/files/:fileId/download')
->alias('/v1/storage/files/:fileId/download', ['bucketId' => 'default'])
->desc('Get File for Download')
->groups(['api', 'storage'])
@@ -1044,7 +1044,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download')
$source = OpenSSL::decrypt(
$source,
$file->getAttribute('openSSLCipher'),
App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')),
Http::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')),
0,
\hex2bin($file->getAttribute('openSSLIV')),
\hex2bin($file->getAttribute('openSSLTag'))
@@ -1096,7 +1096,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download')
}
});
App::get('/v1/storage/buckets/:bucketId/files/:fileId/view')
Http::get('/v1/storage/buckets/:bucketId/files/:fileId/view')
->alias('/v1/storage/files/:fileId/view', ['bucketId' => 'default'])
->desc('Get File for View')
->groups(['api', 'storage'])
@@ -1194,7 +1194,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view')
$source = OpenSSL::decrypt(
$source,
$file->getAttribute('openSSLCipher'),
App::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')),
Http::getEnv('_APP_OPENSSL_KEY_V' . $file->getAttribute('openSSLVersion')),
0,
\hex2bin($file->getAttribute('openSSLIV')),
\hex2bin($file->getAttribute('openSSLTag'))
@@ -1247,7 +1247,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view')
}
});
App::put('/v1/storage/buckets/:bucketId/files/:fileId')
Http::put('/v1/storage/buckets/:bucketId/files/:fileId')
->alias('/v1/storage/files/:fileId', ['bucketId' => 'default'])
->desc('Update File')
->groups(['api', 'storage'])
@@ -1350,7 +1350,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId')
$response->dynamic($file, Response::MODEL_FILE);
});
App::delete('/v1/storage/buckets/:bucketId/files/:fileId')
Http::delete('/v1/storage/buckets/:bucketId/files/:fileId')
->alias('/v1/storage/files/:fileId', ['bucketId' => 'default'])
->desc('Delete File')
->groups(['api', 'storage'])
@@ -1446,7 +1446,7 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId')
$response->noContent();
});
App::get('/v1/storage/usage')
Http::get('/v1/storage/usage')
->desc('Get usage stats for storage')
->groups(['api', 'storage', 'usage'])
->label('scope', 'files.read')
@@ -1462,7 +1462,7 @@ App::get('/v1/storage/usage')
->action(function (string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
@@ -1556,7 +1556,7 @@ App::get('/v1/storage/usage')
$response->dynamic($usage, Response::MODEL_USAGE_STORAGE);
});
App::get('/v1/storage/:bucketId/usage')
Http::get('/v1/storage/:bucketId/usage')
->desc('Get usage stats for a storage bucket')
->groups(['api', 'storage', 'usage'])
->label('scope', 'files.read')
@@ -1579,7 +1579,7 @@ App::get('/v1/storage/:bucketId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
+15 -15
View File
@@ -40,7 +40,7 @@ use Utopia\Http\Validator\ArrayList;
use Utopia\Http\Validator\Assoc;
use Utopia\Http\Validator\Text;
App::post('/v1/teams')
Http::post('/v1/teams')
->desc('Create Team')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].create')
@@ -123,7 +123,7 @@ App::post('/v1/teams')
->dynamic($team, Response::MODEL_TEAM);
});
App::get('/v1/teams')
Http::get('/v1/teams')
->desc('List Teams')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@@ -173,7 +173,7 @@ App::get('/v1/teams')
]), Response::MODEL_TEAM_LIST);
});
App::get('/v1/teams/:teamId')
Http::get('/v1/teams/:teamId')
->desc('Get Team')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@@ -200,7 +200,7 @@ App::get('/v1/teams/:teamId')
$response->dynamic($team, Response::MODEL_TEAM);
});
App::get('/v1/teams/:teamId/prefs')
Http::get('/v1/teams/:teamId/prefs')
->desc('Get Team Preferences')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@@ -228,7 +228,7 @@ App::get('/v1/teams/:teamId/prefs')
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});
App::put('/v1/teams/:teamId')
Http::put('/v1/teams/:teamId')
->desc('Update Name')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].update')
@@ -271,7 +271,7 @@ App::put('/v1/teams/:teamId')
$response->dynamic($team, Response::MODEL_TEAM);
});
App::put('/v1/teams/:teamId/prefs')
Http::put('/v1/teams/:teamId/prefs')
->desc('Update Preferences')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].update.prefs')
@@ -307,7 +307,7 @@ App::put('/v1/teams/:teamId/prefs')
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});
App::delete('/v1/teams/:teamId')
Http::delete('/v1/teams/:teamId')
->desc('Delete Team')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].delete')
@@ -361,7 +361,7 @@ App::delete('/v1/teams/:teamId')
$response->noContent();
});
App::post('/v1/teams/:teamId/memberships')
Http::post('/v1/teams/:teamId/memberships')
->desc('Create Team Membership')
->groups(['api', 'teams', 'auth'])
->label('event', 'teams.[teamId].memberships.[membershipId].create')
@@ -401,7 +401,7 @@ App::post('/v1/teams/:teamId/memberships')
$isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles());
$isAppUser = Auth::isAppUser(Authorization::getRoles());
if (!$isPrivilegedUser && !$isAppUser && empty(App::getEnv('_APP_SMTP_HOST'))) {
if (!$isPrivilegedUser && !$isAppUser && empty(Http::getEnv('_APP_SMTP_HOST'))) {
throw new Exception(Exception::GENERAL_SMTP_DISABLED);
}
@@ -594,7 +594,7 @@ App::post('/v1/teams/:teamId/memberships')
);
});
App::get('/v1/teams/:teamId/memberships')
Http::get('/v1/teams/:teamId/memberships')
->desc('List Team Memberships')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@@ -676,7 +676,7 @@ App::get('/v1/teams/:teamId/memberships')
]), Response::MODEL_MEMBERSHIP_LIST);
});
App::get('/v1/teams/:teamId/memberships/:membershipId')
Http::get('/v1/teams/:teamId/memberships/:membershipId')
->desc('Get Team Membership')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
@@ -718,7 +718,7 @@ App::get('/v1/teams/:teamId/memberships/:membershipId')
$response->dynamic($membership, Response::MODEL_MEMBERSHIP);
});
App::patch('/v1/teams/:teamId/memberships/:membershipId')
Http::patch('/v1/teams/:teamId/memberships/:membershipId')
->desc('Update Membership Roles')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].memberships.[membershipId].update')
@@ -789,7 +789,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId')
);
});
App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
Http::patch('/v1/teams/:teamId/memberships/:membershipId/status')
->desc('Update Team Membership Status')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].memberships.[membershipId].update.status')
@@ -924,7 +924,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
);
});
App::delete('/v1/teams/:teamId/memberships/:membershipId')
Http::delete('/v1/teams/:teamId/memberships/:membershipId')
->desc('Delete Team Membership')
->groups(['api', 'teams'])
->label('event', 'teams.[teamId].memberships.[membershipId].delete')
@@ -990,7 +990,7 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId')
$response->noContent();
});
App::get('/v1/teams/:teamId/logs')
Http::get('/v1/teams/:teamId/logs')
->desc('List Team Logs')
->groups(['api', 'teams'])
->label('scope', 'teams.read')
+28 -28
View File
@@ -88,7 +88,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
return $user;
}
App::post('/v1/users')
Http::post('/v1/users')
->desc('Create User')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -121,7 +121,7 @@ App::post('/v1/users')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/bcrypt')
Http::post('/v1/users/bcrypt')
->desc('Create User with Bcrypt Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -152,7 +152,7 @@ App::post('/v1/users/bcrypt')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/md5')
Http::post('/v1/users/md5')
->desc('Create User with MD5 Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -183,7 +183,7 @@ App::post('/v1/users/md5')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/argon2')
Http::post('/v1/users/argon2')
->desc('Create User with Argon2 Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -214,7 +214,7 @@ App::post('/v1/users/argon2')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/sha')
Http::post('/v1/users/sha')
->desc('Create User with SHA Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -252,7 +252,7 @@ App::post('/v1/users/sha')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/phpass')
Http::post('/v1/users/phpass')
->desc('Create User with PHPass Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -283,7 +283,7 @@ App::post('/v1/users/phpass')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/scrypt')
Http::post('/v1/users/scrypt')
->desc('Create User with Scrypt Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -327,7 +327,7 @@ App::post('/v1/users/scrypt')
->dynamic($user, Response::MODEL_USER);
});
App::post('/v1/users/scrypt-modified')
Http::post('/v1/users/scrypt-modified')
->desc('Create User with Scrypt Modified Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
@@ -361,7 +361,7 @@ App::post('/v1/users/scrypt-modified')
->dynamic($user, Response::MODEL_USER);
});
App::get('/v1/users')
Http::get('/v1/users')
->desc('List Users')
->groups(['api', 'users'])
->label('scope', 'users.read')
@@ -408,7 +408,7 @@ App::get('/v1/users')
]), Response::MODEL_USER_LIST);
});
App::get('/v1/users/:userId')
Http::get('/v1/users/:userId')
->desc('Get User')
->groups(['api', 'users'])
->label('scope', 'users.read')
@@ -434,7 +434,7 @@ App::get('/v1/users/:userId')
$response->dynamic($user, Response::MODEL_USER);
});
App::get('/v1/users/:userId/prefs')
Http::get('/v1/users/:userId/prefs')
->desc('Get User Preferences')
->groups(['api', 'users'])
->label('scope', 'users.read')
@@ -462,7 +462,7 @@ App::get('/v1/users/:userId/prefs')
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});
App::get('/v1/users/:userId/sessions')
Http::get('/v1/users/:userId/sessions')
->desc('List User Sessions')
->groups(['api', 'users'])
->label('scope', 'users.read')
@@ -504,7 +504,7 @@ App::get('/v1/users/:userId/sessions')
]), Response::MODEL_SESSION_LIST);
});
App::get('/v1/users/:userId/memberships')
Http::get('/v1/users/:userId/memberships')
->desc('List User Memberships')
->groups(['api', 'users'])
->label('scope', 'users.read')
@@ -544,7 +544,7 @@ App::get('/v1/users/:userId/memberships')
]), Response::MODEL_MEMBERSHIP_LIST);
});
App::get('/v1/users/:userId/logs')
Http::get('/v1/users/:userId/logs')
->desc('List User Logs')
->groups(['api', 'users'])
->label('scope', 'users.read')
@@ -626,7 +626,7 @@ App::get('/v1/users/:userId/logs')
]), Response::MODEL_LOG_LIST);
});
App::patch('/v1/users/:userId/status')
Http::patch('/v1/users/:userId/status')
->desc('Update User Status')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.status')
@@ -663,7 +663,7 @@ App::patch('/v1/users/:userId/status')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/verification')
Http::patch('/v1/users/:userId/verification')
->desc('Update Email Verification')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.verification')
@@ -699,7 +699,7 @@ App::patch('/v1/users/:userId/verification')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/verification/phone')
Http::patch('/v1/users/:userId/verification/phone')
->desc('Update Phone Verification')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.verification')
@@ -735,7 +735,7 @@ App::patch('/v1/users/:userId/verification/phone')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/name')
Http::patch('/v1/users/:userId/name')
->desc('Update Name')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.name')
@@ -776,7 +776,7 @@ App::patch('/v1/users/:userId/name')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/password')
Http::patch('/v1/users/:userId/password')
->desc('Update Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.password')
@@ -835,7 +835,7 @@ App::patch('/v1/users/:userId/password')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/email')
Http::patch('/v1/users/:userId/email')
->desc('Update Email')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.email')
@@ -882,7 +882,7 @@ App::patch('/v1/users/:userId/email')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/phone')
Http::patch('/v1/users/:userId/phone')
->desc('Update Phone')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.phone')
@@ -927,7 +927,7 @@ App::patch('/v1/users/:userId/phone')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/verification')
Http::patch('/v1/users/:userId/verification')
->desc('Update Email Verification')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.verification')
@@ -963,7 +963,7 @@ App::patch('/v1/users/:userId/verification')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/prefs')
Http::patch('/v1/users/:userId/prefs')
->desc('Update User Preferences')
->groups(['api', 'users'])
->label('event', 'users.[userId].update.prefs')
@@ -997,7 +997,7 @@ App::patch('/v1/users/:userId/prefs')
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});
App::delete('/v1/users/:userId/sessions/:sessionId')
Http::delete('/v1/users/:userId/sessions/:sessionId')
->desc('Delete User Session')
->groups(['api', 'users'])
->label('event', 'users.[userId].sessions.[sessionId].delete')
@@ -1041,7 +1041,7 @@ App::delete('/v1/users/:userId/sessions/:sessionId')
$response->noContent();
});
App::delete('/v1/users/:userId/sessions')
Http::delete('/v1/users/:userId/sessions')
->desc('Delete User Sessions')
->groups(['api', 'users'])
->label('event', 'users.[userId].sessions.[sessionId].delete')
@@ -1084,7 +1084,7 @@ App::delete('/v1/users/:userId/sessions')
$response->noContent();
});
App::delete('/v1/users/:userId')
Http::delete('/v1/users/:userId')
->desc('Delete User')
->groups(['api', 'users'])
->label('event', 'users.[userId].delete')
@@ -1127,7 +1127,7 @@ App::delete('/v1/users/:userId')
$response->noContent();
});
App::get('/v1/users/usage')
Http::get('/v1/users/usage')
->desc('Get usage stats for the users API')
->groups(['api', 'users', 'usage'])
->label('scope', 'users.read')
@@ -1145,7 +1145,7 @@ App::get('/v1/users/usage')
->action(function (string $range, string $provider, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
'period' => '1h',
+14 -14
View File
@@ -40,7 +40,7 @@ Config::setParam('domainVerification', false);
Config::setParam('cookieDomain', 'localhost');
Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE);
App::init()
Http::init()
->groups(['api'])
->inject('utopia')
->inject('request')
@@ -59,7 +59,7 @@ App::init()
$route = $utopia->match($request);
Request::setRoute($route);
$requestFormat = $request->getHeader('x-appwrite-response-format', App::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', ''));
$requestFormat = $request->getHeader('x-appwrite-response-format', Http::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', ''));
if ($requestFormat) {
switch ($requestFormat) {
case version_compare($requestFormat, '0.12.0', '<'):
@@ -94,7 +94,7 @@ App::init()
} else {
Authorization::disable();
$envDomain = App::getEnv('_APP_DOMAIN', '');
$envDomain = Http::getEnv('_APP_DOMAIN', '');
$mainDomain = null;
if (!empty($envDomain) && $envDomain !== 'localhost') {
$mainDomain = $envDomain;
@@ -185,7 +185,7 @@ App::init()
/*
* Response format
*/
$responseFormat = $request->getHeader('x-appwrite-response-format', App::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', ''));
$responseFormat = $request->getHeader('x-appwrite-response-format', Http::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', ''));
if ($responseFormat) {
switch ($responseFormat) {
case version_compare($responseFormat, '0.11.2', '<='):
@@ -216,7 +216,7 @@ App::init()
* As recommended at:
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
*/
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if (Http::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if ($request->getProtocol() !== 'https') {
if ($request->getMethod() !== Request::METHOD_GET) {
throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP.');
@@ -375,7 +375,7 @@ App::init()
}
});
App::options()
Http::options()
->inject('request')
->inject('response')
->action(function (Request $request, Response $response) {
@@ -392,7 +392,7 @@ App::options()
->noContent();
});
App::error()
Http::error()
->inject('error')
->inject('utopia')
->inject('request')
@@ -402,7 +402,7 @@ App::error()
->inject('loggerBreadcrumbs')
->action(function (Throwable $error, App $utopia, Request $request, Response $response, Document $project, ?Logger $logger, array $loggerBreadcrumbs) {
$version = App::getEnv('_APP_VERSION', 'UNKNOWN');
$version = Http::getEnv('_APP_VERSION', 'UNKNOWN');
$route = $utopia->match($request);
if ($logger) {
@@ -443,7 +443,7 @@ App::error()
$action = $route->getLabel("sdk.namespace", "UNKNOWN_NAMESPACE") . '.' . $route->getLabel("sdk.method", "UNKNOWN_METHOD");
$log->setAction($action);
$isProduction = App::getEnv('_APP_ENV', 'development') === 'production';
$isProduction = Http::getEnv('_APP_ENV', 'development') === 'production';
$log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING);
foreach ($loggerBreadcrumbs as $loggerBreadcrumb) {
@@ -519,7 +519,7 @@ App::error()
$type = $error->getType();
$output = ((App::isDevelopment())) ? [
$output = ((Http::isDevelopment())) ? [
'message' => $message,
'code' => $code,
'file' => $file,
@@ -548,7 +548,7 @@ App::error()
$layout
->setParam('title', $project->getAttribute('name') . ' - Error')
->setParam('development', App::isDevelopment())
->setParam('development', Http::isDevelopment())
->setParam('projectName', $project->getAttribute('name'))
->setParam('projectURL', $project->getAttribute('url'))
->setParam('message', $error->getMessage())
@@ -565,7 +565,7 @@ App::error()
);
});
App::get('/robots.txt')
Http::get('/robots.txt')
->desc('Robots.txt File')
->label('scope', 'public')
->label('docs', false)
@@ -575,7 +575,7 @@ App::get('/robots.txt')
$response->text($template->render(false));
});
App::get('/humans.txt')
Http::get('/humans.txt')
->desc('Humans.txt File')
->label('scope', 'public')
->label('docs', false)
@@ -585,7 +585,7 @@ App::get('/humans.txt')
$response->text($template->render(false));
});
App::get('/.well-known/acme-challenge/*')
Http::get('/.well-known/acme-challenge/*')
->desc('SSL Verification')
->label('scope', 'public')
->label('docs', false)
+29 -29
View File
@@ -17,7 +17,7 @@ use Utopia\Http\Validator\WhiteList;
use Utopia\Database\Helpers\ID;
use Utopia\Http\Validator\Nullable;
App::get('/v1/mock/tests/foo')
Http::get('/v1/mock/tests/foo')
->desc('Get Foo')
->groups(['mock'])
->label('scope', 'public')
@@ -35,7 +35,7 @@ App::get('/v1/mock/tests/foo')
->action(function ($x, $y, $z) {
});
App::post('/v1/mock/tests/foo')
Http::post('/v1/mock/tests/foo')
->desc('Post Foo')
->groups(['mock'])
->label('scope', 'public')
@@ -53,7 +53,7 @@ App::post('/v1/mock/tests/foo')
->action(function ($x, $y, $z) {
});
App::patch('/v1/mock/tests/foo')
Http::patch('/v1/mock/tests/foo')
->desc('Patch Foo')
->groups(['mock'])
->label('scope', 'public')
@@ -71,7 +71,7 @@ App::patch('/v1/mock/tests/foo')
->action(function ($x, $y, $z) {
});
App::put('/v1/mock/tests/foo')
Http::put('/v1/mock/tests/foo')
->desc('Put Foo')
->groups(['mock'])
->label('scope', 'public')
@@ -89,7 +89,7 @@ App::put('/v1/mock/tests/foo')
->action(function ($x, $y, $z) {
});
App::delete('/v1/mock/tests/foo')
Http::delete('/v1/mock/tests/foo')
->desc('Delete Foo')
->groups(['mock'])
->label('scope', 'public')
@@ -107,7 +107,7 @@ App::delete('/v1/mock/tests/foo')
->action(function ($x, $y, $z) {
});
App::get('/v1/mock/tests/bar')
Http::get('/v1/mock/tests/bar')
->desc('Get Bar')
->groups(['mock'])
->label('scope', 'public')
@@ -125,7 +125,7 @@ App::get('/v1/mock/tests/bar')
->action(function ($required, $default, $z) {
});
App::post('/v1/mock/tests/bar')
Http::post('/v1/mock/tests/bar')
->desc('Post Bar')
->groups(['mock'])
->label('scope', 'public')
@@ -145,7 +145,7 @@ App::post('/v1/mock/tests/bar')
->action(function ($required, $default, $z) {
});
App::patch('/v1/mock/tests/bar')
Http::patch('/v1/mock/tests/bar')
->desc('Patch Bar')
->groups(['mock'])
->label('scope', 'public')
@@ -163,7 +163,7 @@ App::patch('/v1/mock/tests/bar')
->action(function ($required, $default, $z) {
});
App::put('/v1/mock/tests/bar')
Http::put('/v1/mock/tests/bar')
->desc('Put Bar')
->groups(['mock'])
->label('scope', 'public')
@@ -181,7 +181,7 @@ App::put('/v1/mock/tests/bar')
->action(function ($required, $default, $z) {
});
App::delete('/v1/mock/tests/bar')
Http::delete('/v1/mock/tests/bar')
->desc('Delete Bar')
->groups(['mock'])
->label('scope', 'public')
@@ -200,7 +200,7 @@ App::delete('/v1/mock/tests/bar')
});
/** Endpoint to test if required headers are sent from the SDK */
App::get('/v1/mock/tests/general/headers')
Http::get('/v1/mock/tests/general/headers')
->desc('Get headers')
->groups(['mock'])
->label('scope', 'public')
@@ -228,7 +228,7 @@ App::get('/v1/mock/tests/general/headers')
$response->dynamic(new Document(['result' => $res]), Response::MODEL_MOCK);
});
App::get('/v1/mock/tests/general/download')
Http::get('/v1/mock/tests/general/download')
->desc('Download File')
->groups(['mock'])
->label('scope', 'public')
@@ -252,7 +252,7 @@ App::get('/v1/mock/tests/general/download')
;
});
App::post('/v1/mock/tests/general/upload')
Http::post('/v1/mock/tests/general/upload')
->desc('Upload File')
->groups(['mock'])
->label('scope', 'public')
@@ -340,7 +340,7 @@ App::post('/v1/mock/tests/general/upload')
}
});
App::get('/v1/mock/tests/general/redirect')
Http::get('/v1/mock/tests/general/redirect')
->desc('Redirect')
->groups(['mock'])
->label('scope', 'public')
@@ -358,7 +358,7 @@ App::get('/v1/mock/tests/general/redirect')
$response->redirect('/v1/mock/tests/general/redirect/done');
});
App::get('/v1/mock/tests/general/redirect/done')
Http::get('/v1/mock/tests/general/redirect/done')
->desc('Redirected')
->groups(['mock'])
->label('scope', 'public')
@@ -373,7 +373,7 @@ App::get('/v1/mock/tests/general/redirect/done')
->action(function () {
});
App::get('/v1/mock/tests/general/set-cookie')
Http::get('/v1/mock/tests/general/set-cookie')
->desc('Set Cookie')
->groups(['mock'])
->label('scope', 'public')
@@ -392,7 +392,7 @@ App::get('/v1/mock/tests/general/set-cookie')
$response->addCookie('cookieName', 'cookieValue', \time() + 31536000, '/', $request->getHostname(), true, true);
});
App::get('/v1/mock/tests/general/get-cookie')
Http::get('/v1/mock/tests/general/get-cookie')
->desc('Get Cookie')
->groups(['mock'])
->label('scope', 'public')
@@ -412,7 +412,7 @@ App::get('/v1/mock/tests/general/get-cookie')
}
});
App::get('/v1/mock/tests/general/empty')
Http::get('/v1/mock/tests/general/empty')
->desc('Empty Response')
->groups(['mock'])
->label('scope', 'public')
@@ -429,7 +429,7 @@ App::get('/v1/mock/tests/general/empty')
$response->noContent();
});
App::post('/v1/mock/tests/general/nullable')
Http::post('/v1/mock/tests/general/nullable')
->desc('Nullable Test')
->groups(['mock'])
->label('scope', 'public')
@@ -445,7 +445,7 @@ App::post('/v1/mock/tests/general/nullable')
});
/** Endpoint to test if required headers are sent from the SDK */
App::get('/v1/mock/tests/general/headers')
Http::get('/v1/mock/tests/general/headers')
->desc('Get headers')
->groups(['mock'])
->label('scope', 'public')
@@ -473,7 +473,7 @@ App::get('/v1/mock/tests/general/headers')
$response->dynamic(new Document(['result' => $res]), Response::MODEL_MOCK);
});
App::get('/v1/mock/tests/general/400-error')
Http::get('/v1/mock/tests/general/400-error')
->desc('400 Error')
->groups(['mock'])
->label('scope', 'public')
@@ -489,7 +489,7 @@ App::get('/v1/mock/tests/general/400-error')
throw new Exception(Exception::GENERAL_MOCK, 'Mock 400 error');
});
App::get('/v1/mock/tests/general/500-error')
Http::get('/v1/mock/tests/general/500-error')
->desc('500 Error')
->groups(['mock'])
->label('scope', 'public')
@@ -505,7 +505,7 @@ App::get('/v1/mock/tests/general/500-error')
throw new Exception(Exception::GENERAL_MOCK, 'Mock 500 error', 500);
});
App::get('/v1/mock/tests/general/502-error')
Http::get('/v1/mock/tests/general/502-error')
->desc('502 Error')
->groups(['mock'])
->label('scope', 'public')
@@ -526,7 +526,7 @@ App::get('/v1/mock/tests/general/502-error')
;
});
App::get('/v1/mock/tests/general/oauth2')
Http::get('/v1/mock/tests/general/oauth2')
->desc('OAuth Login')
->groups(['mock'])
->label('scope', 'public')
@@ -542,7 +542,7 @@ App::get('/v1/mock/tests/general/oauth2')
$response->redirect($redirectURI . '?' . \http_build_query(['code' => 'abcdef', 'state' => $state]));
});
App::get('/v1/mock/tests/general/oauth2/token')
Http::get('/v1/mock/tests/general/oauth2/token')
->desc('OAuth2 Token')
->groups(['mock'])
->label('scope', 'public')
@@ -588,7 +588,7 @@ App::get('/v1/mock/tests/general/oauth2/token')
}
});
App::get('/v1/mock/tests/general/oauth2/user')
Http::get('/v1/mock/tests/general/oauth2/user')
->desc('OAuth2 User')
->groups(['mock'])
->label('scope', 'public')
@@ -608,7 +608,7 @@ App::get('/v1/mock/tests/general/oauth2/user')
]);
});
App::get('/v1/mock/tests/general/oauth2/success')
Http::get('/v1/mock/tests/general/oauth2/success')
->desc('OAuth2 Success')
->groups(['mock'])
->label('scope', 'public')
@@ -621,7 +621,7 @@ App::get('/v1/mock/tests/general/oauth2/success')
]);
});
App::get('/v1/mock/tests/general/oauth2/failure')
Http::get('/v1/mock/tests/general/oauth2/failure')
->desc('OAuth2 Failure')
->groups(['mock'])
->label('scope', 'public')
@@ -636,7 +636,7 @@ App::get('/v1/mock/tests/general/oauth2/failure')
]);
});
App::shutdown()
Http::shutdown()
->groups(['mock'])
->inject('utopia')
->inject('response')
+8 -8
View File
@@ -87,7 +87,7 @@ $databaseListener = function (string $event, Document $document, Stats $usage) {
}
};
App::init()
Http::init()
->groups(['api'])
->inject('utopia')
->inject('request')
@@ -155,7 +155,7 @@ App::init()
;
}
$enabled = App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled';
$enabled = Http::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled';
if (
$enabled // Abuse is enabled
@@ -257,7 +257,7 @@ App::init()
}
});
App::init()
Http::init()
->groups(['auth'])
->inject('utopia')
->inject('request')
@@ -317,7 +317,7 @@ App::init()
* Delete older sessions if the number of sessions have crossed
* the session limit set for the project
*/
App::shutdown()
Http::shutdown()
->groups(['session'])
->inject('utopia')
->inject('request')
@@ -350,7 +350,7 @@ App::shutdown()
$dbForProject->deleteCachedDocument('users', $userId);
});
App::shutdown()
Http::shutdown()
->groups(['api'])
->inject('utopia')
->inject('request')
@@ -521,7 +521,7 @@ App::shutdown()
}
if (
App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'
Http::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'
&& $project->getId()
&& !empty($route->getLabel('sdk.namespace', null))
) { // Don't calculate console usage on admin mode
@@ -553,10 +553,10 @@ App::shutdown()
}
});
App::init()
Http::init()
->groups(['usage'])
->action(function () {
if (App::getEnv('_APP_USAGE_STATS', 'enabled') !== 'enabled') {
if (Http::getEnv('_APP_USAGE_STATS', 'enabled') !== 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
});
+2 -2
View File
@@ -4,7 +4,7 @@ use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Utopia\Http\Http;
App::init()
Http::init()
->groups(['web'])
->inject('request')
->inject('response')
@@ -16,7 +16,7 @@ App::init()
;
});
App::get('/console/*')
Http::get('/console/*')
->alias('/')
->alias('auth/*')
->alias('/invite')
+1 -1
View File
@@ -4,7 +4,7 @@ use Appwrite\Utopia\Response;
use Utopia\Http\Http;
use Utopia\Config\Config;
App::get('/versions')
Http::get('/versions')
->desc('Get Version')
->groups(['home'])
->label('scope', 'public')