Migrate backend to Porto architecture and fix minor bugs

- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
This commit is contained in:
F4ilji
2025-05-12 08:47:43 +05:00
parent 76deaf75f3
commit c01016a154
620 changed files with 16218 additions and 6073 deletions
@@ -0,0 +1,30 @@
<?php
namespace App\Ship\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class RateLimitCounterMiddleware
{
public function handle(Request $request, Closure $next)
{
$ip = $request->ip();
$key = 'rate_limit:' . $ip;
$maxAttempts = 5; // Максимальное количество попыток
$decayMinutes = 1; // Время блокировки в минутах
// Получаем текущее количество попыток
$attempts = Cache::get($key, 0);
if ($attempts >= $maxAttempts) {
return response()->json(['message' => 'Слишком много запросов, пожалуйста, попробуйте позже.'], 429);
}
// Увеличиваем количество попыток
Cache::put($key, $attempts + 1, $decayMinutes * 60);
return $next($request);
}
}