Make Chrly's domain configurable

This commit is contained in:
ErickSkrauch 2021-03-04 05:58:07 +01:00
parent 163bbe68a2
commit bd168808b2
5 changed files with 13 additions and 5 deletions

View File

@ -13,6 +13,7 @@ JWT_PRIVATE_PEM_LOCATION=
JWT_PUBLIC_PEM_LOCATION= JWT_PUBLIC_PEM_LOCATION=
## External services ## External services
CHRLY_HOST=skinsystem.ely.by
RECAPTCHA_PUBLIC= RECAPTCHA_PUBLIC=
RECAPTCHA_SECRET= RECAPTCHA_SECRET=
SENTRY_DSN= SENTRY_DSN=

View File

@ -26,7 +26,7 @@ return [
}; };
}, },
common\components\SkinsSystemApi::class => function() { common\components\SkinsSystemApi::class => function() {
return new class extends common\components\SkinsSystemApi { return new class('http://chrly.ely.by') extends common\components\SkinsSystemApi {
public function textures(string $username): ?array { public function textures(string $username): ?array {
return [ return [
'SKIN' => [ 'SKIN' => [

View File

@ -10,10 +10,14 @@ use Yii;
// TODO: convert to complete Chrly client library // TODO: convert to complete Chrly client library
class SkinsSystemApi { class SkinsSystemApi {
private const BASE_DOMAIN = 'http://skinsystem.ely.by'; private string $baseDomain;
private ?ClientInterface $client = null; private ?ClientInterface $client = null;
public function __construct(string $baseDomain) {
$this->baseDomain = $baseDomain;
}
/** /**
* @param string $username * @param string $username
* @throws \GuzzleHttp\Exception\GuzzleException * @throws \GuzzleHttp\Exception\GuzzleException
@ -69,7 +73,7 @@ class SkinsSystemApi {
} }
private function buildUrl(string $url): string { private function buildUrl(string $url): string {
return static::BASE_DOMAIN . $url; return $this->baseDomain . $url;
} }
private function getClient(): ClientInterface { private function getClient(): ClientInterface {

View File

@ -7,7 +7,7 @@ return [
], ],
'components' => [ 'components' => [
'cache' => [ 'cache' => [
'class' => \yii\caching\FileCache::class, 'class' => yii\caching\FileCache::class,
], ],
'security' => [ 'security' => [
// It's allows us to increase tests speed by decreasing password hashing algorithm complexity // It's allows us to increase tests speed by decreasing password hashing algorithm complexity

View File

@ -19,7 +19,10 @@ return [
'singletons' => [ 'singletons' => [
GuzzleHttp\ClientInterface::class => GuzzleHttp\Client::class, GuzzleHttp\ClientInterface::class => GuzzleHttp\Client::class,
Ely\Mojang\Api::class => Ely\Mojang\Api::class, Ely\Mojang\Api::class => Ely\Mojang\Api::class,
common\components\SkinsSystemApi::class => common\components\SkinsSystemApi::class, common\components\SkinsSystemApi::class => [
'class' => common\components\SkinsSystemApi::class,
'__construct()' => 'http://' . (getenv('CHRLY_HOST') ?: 'skinsystem.ely.by'),
],
], ],
], ],
'components' => [ 'components' => [