feat: move server list to app resource
This commit is contained in:
parent
42d78f9a68
commit
741824ef87
|
@ -46,7 +46,8 @@ App::init()
|
|||
->inject('user')
|
||||
->inject('locale')
|
||||
->inject('clients')
|
||||
->action(function (App $utopia, Request $request, Response $response, Document $console, Document $project, Database $dbForConsole, Document $user, Locale $locale, array $clients) {
|
||||
->inject('servers')
|
||||
->action(function (App $utopia, Request $request, Response $response, Document $console, Document $project, Database $dbForConsole, Document $user, Locale $locale, array $clients, array $servers) {
|
||||
/*
|
||||
* Request format
|
||||
*/
|
||||
|
@ -308,22 +309,8 @@ App::init()
|
|||
$dbForConsole->deleteCachedDocument('projects', $project->getId());
|
||||
}
|
||||
|
||||
$sdkValidator = new WhiteList([
|
||||
'nodejs',
|
||||
'deno',
|
||||
'php',
|
||||
'python',
|
||||
'ruby',
|
||||
'go',
|
||||
'java',
|
||||
'dotnet',
|
||||
'dart',
|
||||
'kotlin',
|
||||
'swift'
|
||||
], true);
|
||||
|
||||
$sdkValidator = new WhiteList($servers, true);
|
||||
$sdk = $request->getHeader('x-sdk-name', 'UNKNOWN');
|
||||
|
||||
if ($sdkValidator->isValid($sdk)) {
|
||||
$sdks = $key->getAttribute('sdks', []);
|
||||
if (!in_array($sdk, $sdks)) {
|
||||
|
|
11
app/init.php
11
app/init.php
|
@ -998,3 +998,14 @@ App::setResource('phone', function () {
|
|||
default => null
|
||||
};
|
||||
});
|
||||
|
||||
App::setResource('servers', function () {
|
||||
$platforms = Config::getParam('platforms');
|
||||
$server = $platforms[APP_PLATFORM_SERVER];
|
||||
|
||||
$languages = array_map(function ($language) {
|
||||
return strtolower($language['name']);
|
||||
}, $server['languages']);
|
||||
|
||||
return $languages;
|
||||
});
|
Loading…
Reference in a new issue