use config instead of env()

This commit is contained in:
peaklabs-dev
2024-11-12 15:53:05 +01:00
parent 97f868a285
commit 1ffa88acf0
9 changed files with 37 additions and 31 deletions

View File

@@ -57,7 +57,7 @@ class Dev extends Command
{ {
// Generate APP_KEY if not exists // Generate APP_KEY if not exists
if (empty(env('APP_KEY'))) { if (empty(config('app.key'))) {
echo "Generating APP_KEY.\n"; echo "Generating APP_KEY.\n";
Artisan::call('key:generate'); Artisan::call('key:generate');
} }

View File

@@ -77,8 +77,8 @@ class Init extends Command
echo "Could not setup dynamic configuration: {$e->getMessage()}\n"; echo "Could not setup dynamic configuration: {$e->getMessage()}\n";
} }
$settings = instanceSettings(); $settings = instanceSettings();
if (! is_null(env('AUTOUPDATE', null))) { if (! is_null(config('constants.coolify.autoupdate', null))) {
if (env('AUTOUPDATE') == true) { if (config('constants.coolify.autoupdate') == true) {
$settings->update(['is_auto_update_enabled' => true]); $settings->update(['is_auto_update_enabled' => true]);
} else { } else {
$settings->update(['is_auto_update_enabled' => false]); $settings->update(['is_auto_update_enabled' => false]);

View File

@@ -57,7 +57,7 @@ class SyncBunny extends Command
PendingRequest::macro('storage', function ($fileName) use ($that) { PendingRequest::macro('storage', function ($fileName) use ($that) {
$headers = [ $headers = [
'AccessKey' => env('BUNNY_STORAGE_API_KEY'), 'AccessKey' => config('constants.bunny.storage_api_key'),
'Accept' => 'application/json', 'Accept' => 'application/json',
'Content-Type' => 'application/octet-stream', 'Content-Type' => 'application/octet-stream',
]; ];
@@ -69,7 +69,7 @@ class SyncBunny extends Command
}); });
PendingRequest::macro('purge', function ($url) use ($that) { PendingRequest::macro('purge', function ($url) use ($that) {
$headers = [ $headers = [
'AccessKey' => env('BUNNY_API_KEY'), 'AccessKey' => config('constants.bunny.api_key'),
'Accept' => 'application/json', 'Accept' => 'application/json',
]; ];
$that->info('Purging: '.$url); $that->info('Purging: '.$url);

View File

@@ -359,7 +359,7 @@ function isDev(): bool
function isCloud(): bool function isCloud(): bool
{ {
return ! config('constants.coolify.self_hosted'); return ! config('.self_hosted');
} }
function translate_cron_expression($expression_to_validate): string function translate_cron_expression($expression_to_validate): string
@@ -989,7 +989,7 @@ function generateEnvValue(string $command, Service|Application|null $service = n
function getRealtime() function getRealtime()
{ {
$envDefined = env('PUSHER_PORT'); $envDefined = config('constants.pusher.port');
if (empty($envDefined)) { if (empty($envDefined)) {
$url = Url::fromString(Request::getSchemeAndHttpHost()); $url = Url::fromString(Request::getSchemeAndHttpHost());
$port = $url->getPort(); $port = $url->getPort();

View File

@@ -29,6 +29,7 @@ return [
'pusher' => [ 'pusher' => [
'host' => env('PUSHER_HOST'), 'host' => env('PUSHER_HOST'),
'port' => env('PUSHER_PORT'),
'app_key' => env('PUSHER_APP_KEY'), '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' => [ 'limits' => [
'trial_period' => 0, 'trial_period' => 0,
'server' => [ 'server' => [
@@ -89,4 +76,23 @@ return [
'dynamic' => true, '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'),
],
]; ];

View File

@@ -3,11 +3,11 @@
return [ return [
// @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ // @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 // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // 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 // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@@ -84,9 +84,9 @@
window.Pusher = Pusher; window.Pusher = Pusher;
window.Echo = new Echo({ window.Echo = new Echo({
broadcaster: 'pusher', broadcaster: 'pusher',
cluster: "{{ env('PUSHER_HOST') }}" || window.location.hostname, cluster: "{{ config('constants.pusher.host') }}" || window.location.hostname,
key: "{{ env('PUSHER_APP_KEY') }}" || 'coolify', key: "{{ config('constants.pusher.app_key') }}" || 'coolify',
wsHost: "{{ env('PUSHER_HOST') }}" || window.location.hostname, wsHost: "{{ config('constants.pusher.host') }}" || window.location.hostname,
wsPort: "{{ getRealtime() }}", wsPort: "{{ getRealtime() }}",
wssPort: "{{ getRealtime() }}", wssPort: "{{ getRealtime() }}",
forceTLS: false, forceTLS: false,

View File

@@ -26,9 +26,9 @@
<script> <script>
// expose terminal config to the terminal.js file // expose terminal config to the terminal.js file
window.terminalConfig = { window.terminalConfig = {
protocol: "{{ env('TERMINAL_PROTOCOL') }}", protocol: "{{ config('constants.terminal.protocol') }}",
host: "{{ env('TERMINAL_HOST') }}", host: "{{ config('constants.terminal.host') }}",
port: "{{ env('TERMINAL_PORT') }}" port: "{{ config('constants.terminal.port') }}"
} }
</script> </script>
@endscript @endscript

View File

@@ -102,7 +102,7 @@
placeholder="1.1.1.1,8.8.8.8" /> placeholder="1.1.1.1,8.8.8.8" />
<h4 class="pt-6">Update</h4> <h4 class="pt-6">Update</h4>
<div class="text-right md:w-96"> <div class="text-right md:w-96">
@if (!is_null(env('AUTOUPDATE', null))) @if (!is_null(config('constants.coolify.autoupdate', null)))
<div class="text-right md:w-96"> <div class="text-right md:w-96">
<x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there." <x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there."
disabled id="is_auto_update_enabled" label="Enabled" /> disabled id="is_auto_update_enabled" label="Enabled" />
@@ -119,7 +119,7 @@
<x-forms.button wire:click='checkManually'>Check Manually</x-forms.button> <x-forms.button wire:click='checkManually'>Check Manually</x-forms.button>
</div> </div>
@if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled) @if (is_null(config('constants.coolify.autoupdate', null)) && $is_auto_update_enabled)
<x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *" <x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *"
helper="Cron expression for auto update frequency (automatically update coolify).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every day at 00:00" /> helper="Cron expression for auto update frequency (automatically update coolify).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every day at 00:00" />
@endif @endif