1
0
Fork 0
mirror of synced 2024-05-20 20:52:36 +12:00

Merge pull request #941 from appwrite/feat-endpoint-for-version-numbers

Added latest versions endpoint
This commit is contained in:
Eldad A. Fux 2021-02-25 06:37:50 +02:00 committed by GitHub
commit 214bf33254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

View file

@ -10,6 +10,7 @@
- Force adding a security email on setup
- Better error logs on appwrite cretificates worker## Upgrades
- SMTP is now disabled by default, no dummy SMTP is included in setup
- Added a new endpoint that returns the server and SDKs latest versions numbers #941
## Upgrades

View file

@ -375,4 +375,40 @@ App::get('/specs/:format')
$response
->json($specs->parse());
});
App::get('/versions')
->desc('Get Version')
->groups(['web', 'home'])
->label('scope', 'public')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
$platforms = Config::getParam('platforms');
$versions = [
'server' => APP_VERSION_STABLE,
];
foreach($platforms as $platform) {
$languages = $platform['languages'] ?? [];
foreach ($languages as $key => $language) {
if(isset($language['dev']) && $language['dev']) {
continue;
}
if(isset($language['enabled']) && !$language['enabled']) {
continue;
}
$platformKey = $platform['key'] ?? '';
$languageKey = $language['key'] ?? '';
$version = $language['version'] ?? '';
$versions[$platformKey . '-' . $languageKey] = $version;
}
}
$response->json($versions);
});

View file

@ -186,4 +186,27 @@ class HTTPTest extends Scope
$this->assertEquals($body['continents']['AN'], 'Antarctica');
$this->assertEquals($body['continents']['AS'], 'Asia');
}
public function testVersions() {
/**
* Test without header
*/
$response = $this->client->call(Client::METHOD_GET, '/versions', array_merge([
'content-type' => 'application/json',
], $this->getHeaders()));
$body = $response['body'];
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsString($body['server']);
$this->assertIsString($body['client-web']);
$this->assertIsString($body['client-flutter']);
$this->assertIsString($body['console-web']);
$this->assertIsString($body['server-nodejs']);
$this->assertIsString($body['server-deno']);
$this->assertIsString($body['server-php']);
$this->assertIsString($body['server-python']);
$this->assertIsString($body['server-ruby']);
$this->assertIsString($body['server-cli']);
}
}