mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
update: init with module structure.
This commit is contained in:
@@ -1582,20 +1582,6 @@ foreach (Config::getParam('services', []) as $service) {
|
||||
}
|
||||
}
|
||||
|
||||
// legacy controller init hooks as the endpoint controller logic is now moved to a module structure.
|
||||
// 1. databases
|
||||
App::init()
|
||||
->groups(['api', 'database'])
|
||||
->inject('request')
|
||||
->inject('dbForProject')
|
||||
->action(function (Request $request, Database $dbForProject) {
|
||||
$timeout = \intval($request->getHeader('x-appwrite-timeout'));
|
||||
|
||||
if (!empty($timeout) && App::isDevelopment()) {
|
||||
$dbForProject->setTimeout($timeout);
|
||||
}
|
||||
});
|
||||
|
||||
// Check for any errors found while we were initialising the SDK Methods.
|
||||
if (!empty(Method::getErrors())) {
|
||||
throw new \Exception('Errors found during SDK initialization:' . PHP_EOL . implode(PHP_EOL, Method::getErrors()));
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Platform\Modules\Databases\Http\Init;
|
||||
|
||||
use Appwrite\Utopia\Request;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Platform\Action;
|
||||
|
||||
/**
|
||||
* Project database timeout,
|
||||
*/
|
||||
class Timeout extends Action
|
||||
{
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'projectDatabaseTimeout';
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->setType(Action::TYPE_INIT)
|
||||
->groups(['api', 'database'])
|
||||
->inject('request')
|
||||
->inject('dbForProject')
|
||||
->callback(function (Request $request, Database $dbForProject) {
|
||||
$timeout = \intval($request->getHeader('x-appwrite-timeout'));
|
||||
|
||||
if (!empty($timeout) && App::isDevelopment()) {
|
||||
$dbForProject->setTimeout($timeout);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Appwrite\Platform\Modules\Databases\Services;
|
||||
|
||||
use Appwrite\Platform\Modules\Databases\Http\Init\Timeout;
|
||||
use Appwrite\Platform\Modules\Databases\Services\Registry\Collections as CollectionsRegistry;
|
||||
use Appwrite\Platform\Modules\Databases\Services\Registry\Databases as DatabasesRegistry;
|
||||
use Appwrite\Platform\Modules\Databases\Services\Registry\Tables as TablesRegistry;
|
||||
@@ -14,6 +15,7 @@ class Http extends Service
|
||||
$this->type = Service::TYPE_HTTP;
|
||||
|
||||
foreach ([
|
||||
Timeout::class,
|
||||
DatabasesRegistry::class,
|
||||
CollectionsRegistry::class,
|
||||
TablesRegistry::class,
|
||||
|
||||
Reference in New Issue
Block a user