Test console init
This commit is contained in:
parent
507e0327e3
commit
7797401848
|
@ -22,15 +22,45 @@ Config::setParam('domainVerification', false);
|
|||
Config::setParam('cookieDomain', 'localhost');
|
||||
Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE);
|
||||
|
||||
App::init(function ($utopia, $request, $response, $console, $project, $user, $locale, $clients) {
|
||||
App::init(function ($utopia, $request, $response, $console, $project, $user, $locale, $clients, $dbForConsole) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $console */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Utopia\Locale\Locale $locale */
|
||||
/** @var bool $mode */
|
||||
/** @var array $clients */
|
||||
/** @var Utopia\Database\Database $dbForConsole */
|
||||
|
||||
if(!$dbForConsole->exists()) {
|
||||
|
||||
Console::success('init database!!');
|
||||
|
||||
$collections = Config::getParam('collections2', []); /** @var array $collections */
|
||||
|
||||
$dbForConsole->create();
|
||||
|
||||
foreach ($collections as $key => $collection) {
|
||||
$dbForConsole->createCollection($key);
|
||||
|
||||
foreach ($collection['attributes'] as $i => $attribute) {
|
||||
$dbForConsole->createAttribute(
|
||||
$key,
|
||||
$attribute['$id'],
|
||||
$attribute['type'],
|
||||
$attribute['size'],
|
||||
$attribute['required'],
|
||||
$attribute['signed'],
|
||||
$attribute['array'],
|
||||
$attribute['filters'],
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($collection['indexes'] as $i => $index) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$localeParam = (string)$request->getParam('locale', $request->getHeader('x-appwrite-locale', ''));
|
||||
|
||||
|
@ -230,7 +260,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
throw new Exception('Password reset is required', 412);
|
||||
}
|
||||
|
||||
}, ['utopia', 'request', 'response', 'console', 'project', 'user', 'locale', 'clients']);
|
||||
}, ['utopia', 'request', 'response', 'console', 'project', 'user', 'locale', 'clients', 'dbForConsole']);
|
||||
|
||||
App::options(function ($request, $response) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
|
|
10
app/init.php
10
app/init.php
|
@ -522,12 +522,20 @@ App::setResource('dbForExternal', function($register, $project) {
|
|||
$cache = new Cache(new RedisCache($register->get('cache')));
|
||||
|
||||
$database = new DatabaseDatabase(new MariaDB($register->get('db')), $cache);
|
||||
$database->setNamespace('project_external_'.$project->getId());
|
||||
$database->setNamespace('project_'.$project->getId().'_external');
|
||||
|
||||
return $database;
|
||||
}, ['register', 'project']);
|
||||
|
||||
App::setResource('dbForConsole', function($register, $project) {
|
||||
$cache = new Cache(new RedisCache($register->get('cache')));
|
||||
|
||||
$database = new DatabaseDatabase(new MariaDB($register->get('db')), $cache);
|
||||
$database->setNamespace('project_console_internal');
|
||||
|
||||
return $database;
|
||||
}, ['register', 'project']);
|
||||
|
||||
App::setResource('mode', function($request) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
return $request->getParam('mode', $request->getHeader('x-appwrite-mode', APP_MODE_DEFAULT));
|
||||
|
|
30
composer.lock
generated
30
composer.lock
generated
|
@ -1211,16 +1211,16 @@
|
|||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1244,7 +1244,7 @@
|
|||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
|
@ -1255,9 +1255,9 @@
|
|||
"psr-3"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/log/tree/1.1.3"
|
||||
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
||||
},
|
||||
"time": "2020-03-23T09:12:05+00:00"
|
||||
"time": "2021-05-03T11:20:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
|
@ -1923,7 +1923,7 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database",
|
||||
"reference": "43744d220c41048d677643c70a0aa3ab90652e13"
|
||||
"reference": "2299091c63aec2315a4f40bc8dd16968c5bec6bf"
|
||||
},
|
||||
"require": {
|
||||
"ext-mongodb": "*",
|
||||
|
@ -1970,7 +1970,7 @@
|
|||
"upf",
|
||||
"utopia"
|
||||
],
|
||||
"time": "2021-05-03T11:07:15+00:00"
|
||||
"time": "2021-05-03T22:49:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
@ -3305,16 +3305,16 @@
|
|||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v4.10.4",
|
||||
"version": "v4.10.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e"
|
||||
"reference": "4432ba399e47c66624bc73c8c0f811e5c109576f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c6d052fc58cb876152f89f532b95a8d7907e7f0e",
|
||||
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f",
|
||||
"reference": "4432ba399e47c66624bc73c8c0f811e5c109576f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3355,9 +3355,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.4"
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5"
|
||||
},
|
||||
"time": "2020-12-20T10:01:03+00:00"
|
||||
"time": "2021-05-03T19:11:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "openlss/lib-array2xml",
|
||||
|
|
Loading…
Reference in a new issue