Merge pull request #941 from appwrite/feat-endpoint-for-version-numbers
Added latest versions endpoint
This commit is contained in:
commit
214bf33254
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
|
@ -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']);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue