fix: improve API error handling, add fallback UI, and optimize Nginx connection settings

This commit is contained in:
Ümit Tunç
2026-04-07 15:59:30 +03:00
parent 747043d616
commit 266447e03d
3 changed files with 46 additions and 13 deletions
+19 -1
View File
@@ -4,6 +4,14 @@ server {
root /var/www/public; root /var/www/public;
index index.php index.html; 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 # HTTPS için proxy headers
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Port $server_port;
@@ -31,8 +39,18 @@ server {
# Timeout ayarları # Timeout ayarları
fastcgi_read_timeout 300; fastcgi_read_timeout 300;
fastcgi_connect_timeout 300; fastcgi_connect_timeout 60;
fastcgi_send_timeout 300; 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 # Gizli dosyaları engelle
+8 -6
View File
@@ -1,3 +1,4 @@
@if($rate)
<div class="card"> <div class="card">
<div class="title"> <div class="title">
@@ -5,10 +6,10 @@
{{$currencyName}} {{$currencyName}}
</p> </p>
<p class="percent" style="color: {{ $rate['Change'] > 0 ? 'green' : '#B9101E' }}"> <p class="percent" style="color: {{ ($rate['Change'] ?? 0) > 0 ? 'green' : '#B9101E' }}">
{{ $rate['Change'] }}% {{ $rate['Change'] ?? 0 }}%
</p> </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> <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 @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> <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"> <div class="data">
<p> <p>
{{$rate['Selling']}} {{$rate['Selling'] ?? '0.00'}}
</p> </p>
<div class="range"> <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> </div>
</div> </div>
@endif
+19 -6
View File
@@ -128,24 +128,37 @@
</header> </header>
<main class="mt-6"> <main class="mt-6">
@php @php
$response = file_get_contents('https://finance.truncgil.com/api/today.json'); try {
$data = json_decode($response, true); $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']; $currencies = ['USD', 'EUR', 'GBP', 'GRA', 'BTC', 'ETH', 'XRP', 'LTC'];
$rates = []; $rates = [];
foreach ($currencies as $currency) { if (isset($data['Rates'])) {
$rates[$currency] = $data['Rates'][$currency] ?? null; foreach ($currencies as $currency) {
if (isset($data['Rates'][$currency])) {
$rates[$currency] = $data['Rates'][$currency];
}
}
} }
@endphp @endphp
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6"> <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"> <div class="w-full md:w-auto">
@include('currency', [ @include('currency', [
'currencyName' => $currencyName, 'currencyName' => $currencyName,
'rate' => $rate 'rate' => $rate
]) ])
</div> </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> </div>