Added latest versions endpoint
This commit is contained in:
parent
bf2a17139a
commit
b8518ed6f5
|
@ -375,4 +375,40 @@ App::get('/specs/:format')
|
||||||
|
|
||||||
$response
|
$response
|
||||||
->json($specs->parse());
|
->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,43 @@ class HTTPTest extends Scope
|
||||||
$this->assertEquals($body['continents']['AN'], 'Antarctica');
|
$this->assertEquals($body['continents']['AN'], 'Antarctica');
|
||||||
$this->assertEquals($body['continents']['AS'], 'Asia');
|
$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']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test with header
|
||||||
|
*/
|
||||||
|
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
|
'x-appwrite-response-format' => '0.6.2'
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$body = $response['body'];
|
||||||
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
$this->assertEquals($body['sum'], 7);
|
||||||
|
$this->assertEquals($body['continents']['AF'], 'Africa');
|
||||||
|
$this->assertEquals($body['continents']['AN'], 'Antarctica');
|
||||||
|
$this->assertEquals($body['continents']['AS'], 'Asia');
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue