fix: improve API error handling, add fallback UI, and optimize Nginx connection settings
This commit is contained in:
+19
-1
@@ -4,6 +4,14 @@ server {
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Keep-alive ve connection ayarları (bağlantı birikmesini önlemek için)
|
||||
keepalive_timeout 65;
|
||||
keepalive_requests 100;
|
||||
client_max_body_size 20M;
|
||||
client_body_timeout 60s;
|
||||
client_header_timeout 60s;
|
||||
send_timeout 60s;
|
||||
|
||||
# HTTPS için proxy headers
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
@@ -31,8 +39,18 @@ server {
|
||||
|
||||
# Timeout ayarları
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_connect_timeout 60;
|
||||
fastcgi_send_timeout 300;
|
||||
|
||||
# FastCGI keep-alive ve buffer ayarları (bağlantı birikmesini önlemek için)
|
||||
fastcgi_keep_conn on;
|
||||
fastcgi_buffering on;
|
||||
fastcgi_buffer_size 4k;
|
||||
fastcgi_buffers 8 4k;
|
||||
fastcgi_busy_buffers_size 8k;
|
||||
|
||||
# Connection pool ayarları
|
||||
fastcgi_max_temp_file_size 0;
|
||||
}
|
||||
|
||||
# Gizli dosyaları engelle
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@if($rate)
|
||||
<div class="card">
|
||||
<div class="title">
|
||||
|
||||
@@ -5,10 +6,10 @@
|
||||
|
||||
{{$currencyName}}
|
||||
</p>
|
||||
<p class="percent" style="color: {{ $rate['Change'] > 0 ? 'green' : '#B9101E' }}">
|
||||
{{ $rate['Change'] }}%
|
||||
<p class="percent" style="color: {{ ($rate['Change'] ?? 0) > 0 ? 'green' : '#B9101E' }}">
|
||||
{{ $rate['Change'] ?? 0 }}%
|
||||
</p>
|
||||
@if($rate['Change'] > 0)
|
||||
@if(($rate['Change'] ?? 0) > 0)
|
||||
<svg width="20" height="20" fill="green" style="position: relative; top: -2px;" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg" transform="rotate(180)"> <path d="M384 576q0-26 19-45t45-19h896q26 0 45 19t19 45-19 45l-448 448q-19 19-45 19t-45-19l-448-448q-19-19-19-45z"></path> </svg>
|
||||
@else
|
||||
<svg width="20" height="20" fill="#B9101E" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"> <path d="M384 576q0-26 19-45t45-19h896q26 0 45 19t19 45-19 45l-448 448q-19 19-45 19t-45-19l-448-448q-19-19-19-45z"></path> </svg>
|
||||
@@ -19,12 +20,13 @@
|
||||
<div class="data">
|
||||
<p>
|
||||
|
||||
{{$rate['Selling']}} ₺
|
||||
{{$rate['Selling'] ?? '0.00'}} ₺
|
||||
</p>
|
||||
|
||||
<div class="range">
|
||||
<div class="fill" style="background-color: {{ $rate['Change'] > 0 ? 'green' : '#B9101E' }};">
|
||||
<div class="fill" style="background-color: {{ ($rate['Change'] ?? 0) > 0 ? 'green' : '#B9101E' }};">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@@ -128,24 +128,37 @@
|
||||
</header>
|
||||
<main class="mt-6">
|
||||
@php
|
||||
$response = file_get_contents('https://finance.truncgil.com/api/today.json');
|
||||
$data = json_decode($response, true);
|
||||
try {
|
||||
$response = @file_get_contents('https://finance.truncgil.com/api/today.json');
|
||||
$data = $response ? json_decode($response, true) : null;
|
||||
} catch (\Exception $e) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
$currencies = ['USD', 'EUR', 'GBP', 'GRA', 'BTC', 'ETH', 'XRP', 'LTC'];
|
||||
$rates = [];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$rates[$currency] = $data['Rates'][$currency] ?? null;
|
||||
if (isset($data['Rates'])) {
|
||||
foreach ($currencies as $currency) {
|
||||
if (isset($data['Rates'][$currency])) {
|
||||
$rates[$currency] = $data['Rates'][$currency];
|
||||
}
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
@foreach($rates AS $currencyName => $rate)
|
||||
@forelse($rates AS $currencyName => $rate)
|
||||
<div class="w-full md:w-auto">
|
||||
@include('currency', [
|
||||
'currencyName' => $currencyName,
|
||||
'rate' => $rate
|
||||
])
|
||||
</div>
|
||||
@endforeach
|
||||
@empty
|
||||
<div class="col-span-full text-center py-10">
|
||||
<p class="text-gray-500">Service temporarily unavailable. Please try again later.</p>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user