update: move the init hook.

This commit is contained in:
Darshan 2025-05-04 13:37:25 +05:30
parent b3b9961860
commit 9c1ec6fe02
2 changed files with 14 additions and 12 deletions

View file

@ -50,18 +50,6 @@ use Utopia\Validator\JSON;
use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
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);
}
});
App::post('/v1/databases')
->desc('Create database')
->groups(['api', 'database'])

View file

@ -1576,6 +1576,20 @@ 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()));