From 1ffa88acf040e626ebb4f822cd08ca70c55ea99e Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:53:05 +0100 Subject: [PATCH] use config instead of env() --- app/Console/Commands/Dev.php | 2 +- app/Console/Commands/Init.php | 4 +-- app/Console/Commands/SyncBunny.php | 4 +-- bootstrap/helpers/shared.php | 4 +-- config/constants.php | 34 +++++++++++-------- config/sentry.php | 4 +-- resources/views/layouts/base.blade.php | 6 ++-- .../project/shared/terminal.blade.php | 6 ++-- .../views/livewire/settings/index.blade.php | 4 +-- 9 files changed, 37 insertions(+), 31 deletions(-) diff --git a/app/Console/Commands/Dev.php b/app/Console/Commands/Dev.php index 118846304..962000d07 100644 --- a/app/Console/Commands/Dev.php +++ b/app/Console/Commands/Dev.php @@ -57,7 +57,7 @@ class Dev extends Command { // Generate APP_KEY if not exists - if (empty(env('APP_KEY'))) { + if (empty(config('app.key'))) { echo "Generating APP_KEY.\n"; Artisan::call('key:generate'); } diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index e81b22ee6..bbf1dc093 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -77,8 +77,8 @@ class Init extends Command echo "Could not setup dynamic configuration: {$e->getMessage()}\n"; } $settings = instanceSettings(); - if (! is_null(env('AUTOUPDATE', null))) { - if (env('AUTOUPDATE') == true) { + if (! is_null(config('constants.coolify.autoupdate', null))) { + if (config('constants.coolify.autoupdate') == true) { $settings->update(['is_auto_update_enabled' => true]); } else { $settings->update(['is_auto_update_enabled' => false]); diff --git a/app/Console/Commands/SyncBunny.php b/app/Console/Commands/SyncBunny.php index 228467f88..df1903828 100644 --- a/app/Console/Commands/SyncBunny.php +++ b/app/Console/Commands/SyncBunny.php @@ -57,7 +57,7 @@ class SyncBunny extends Command PendingRequest::macro('storage', function ($fileName) use ($that) { $headers = [ - 'AccessKey' => env('BUNNY_STORAGE_API_KEY'), + 'AccessKey' => config('constants.bunny.storage_api_key'), 'Accept' => 'application/json', 'Content-Type' => 'application/octet-stream', ]; @@ -69,7 +69,7 @@ class SyncBunny extends Command }); PendingRequest::macro('purge', function ($url) use ($that) { $headers = [ - 'AccessKey' => env('BUNNY_API_KEY'), + 'AccessKey' => config('constants.bunny.api_key'), 'Accept' => 'application/json', ]; $that->info('Purging: '.$url); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 47fd21df7..efda02496 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -359,7 +359,7 @@ function isDev(): bool function isCloud(): bool { - return ! config('constants.coolify.self_hosted'); + return ! config('.self_hosted'); } function translate_cron_expression($expression_to_validate): string @@ -989,7 +989,7 @@ function generateEnvValue(string $command, Service|Application|null $service = n function getRealtime() { - $envDefined = env('PUSHER_PORT'); + $envDefined = config('constants.pusher.port'); if (empty($envDefined)) { $url = Url::fromString(Request::getSchemeAndHttpHost()); $port = $url->getPort(); diff --git a/config/constants.php b/config/constants.php index d8e8223cd..5c54cea0d 100644 --- a/config/constants.php +++ b/config/constants.php @@ -29,6 +29,7 @@ return [ 'pusher' => [ 'host' => env('PUSHER_HOST'), + 'port' => env('PUSHER_PORT'), 'app_key' => env('PUSHER_APP_KEY'), ], @@ -56,20 +57,6 @@ return [ ], ], - 'waitlist' => [ - 'enabled' => env('WAITLIST', true), - 'expiration' => 10, - ], - - 'sentry' => [ - 'sentry_dsn' => env('SENTRY_DSN'), - ], - - 'webhooks' => [ - 'feedback_discord_webhook' => env('FEEDBACK_DISCORD_WEBHOOK'), - 'dev_webhook' => env('SERVEO_URL'), - ], - 'limits' => [ 'trial_period' => 0, 'server' => [ @@ -89,4 +76,23 @@ return [ 'dynamic' => true, ], ], + + 'waitlist' => [ + 'enabled' => env('WAITLIST', true), + 'expiration' => 10, + ], + + 'sentry' => [ + 'sentry_dsn' => env('SENTRY_DSN'), + ], + + 'webhooks' => [ + 'feedback_discord_webhook' => env('FEEDBACK_DISCORD_WEBHOOK'), + 'dev_webhook' => env('SERVEO_URL'), + ], + + 'bunny' => [ + 'storage_api_key' => env('BUNNY_STORAGE_API_KEY'), + 'api_key' => env('BUNNY_API_KEY'), + ], ]; diff --git a/config/sentry.php b/config/sentry.php index 232070705..0efb4a0e2 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -3,11 +3,11 @@ return [ // @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ - 'dsn' => config('coolify.sentry_dsn'), + 'dsn' => config('constants.sentry.sentry_dsn'), // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.368', + 'release' => config('constants.coolify.version'), // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index 78ae02f3a..8c5017e03 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -84,9 +84,9 @@ window.Pusher = Pusher; window.Echo = new Echo({ broadcaster: 'pusher', - cluster: "{{ env('PUSHER_HOST') }}" || window.location.hostname, - key: "{{ env('PUSHER_APP_KEY') }}" || 'coolify', - wsHost: "{{ env('PUSHER_HOST') }}" || window.location.hostname, + cluster: "{{ config('constants.pusher.host') }}" || window.location.hostname, + key: "{{ config('constants.pusher.app_key') }}" || 'coolify', + wsHost: "{{ config('constants.pusher.host') }}" || window.location.hostname, wsPort: "{{ getRealtime() }}", wssPort: "{{ getRealtime() }}", forceTLS: false, diff --git a/resources/views/livewire/project/shared/terminal.blade.php b/resources/views/livewire/project/shared/terminal.blade.php index 3bbc9946c..b15f2aaa9 100644 --- a/resources/views/livewire/project/shared/terminal.blade.php +++ b/resources/views/livewire/project/shared/terminal.blade.php @@ -26,9 +26,9 @@ @endscript diff --git a/resources/views/livewire/settings/index.blade.php b/resources/views/livewire/settings/index.blade.php index 42bdfc267..6eef2982e 100644 --- a/resources/views/livewire/settings/index.blade.php +++ b/resources/views/livewire/settings/index.blade.php @@ -102,7 +102,7 @@ placeholder="1.1.1.1,8.8.8.8" />

Update

- @if (!is_null(env('AUTOUPDATE', null))) + @if (!is_null(config('constants.coolify.autoupdate', null)))
@@ -119,7 +119,7 @@ Check Manually
- @if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled) + @if (is_null(config('constants.coolify.autoupdate', null)) && $is_auto_update_enabled) @endif