varias alteracoes
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-06 14:50:12 +02:00
parent 4f35313d06
commit e65cb26901
333 changed files with 54656 additions and 2058 deletions
+32 -2
View File
@@ -3,14 +3,16 @@
use App\Http\Middleware\HandleAppearance;
use App\Http\Middleware\HandleInertiaRequests;
use App\Http\Middleware\PreserveFormFeedback;
use App\Http\Middleware\EnsureSimulationRecoveryCookie;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Database\QueryException;
use Illuminate\Database\ConnectionException;
use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
@@ -20,7 +22,7 @@ return Application::configure(basePath: dirname(__DIR__))
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->encryptCookies(except: ['appearance', 'sidebar_state']);
$middleware->encryptCookies(except: ['appearance', 'sidebar_state', EnsureSimulationRecoveryCookie::NAME]);
$middleware->web(append: [
HandleAppearance::class,
@@ -42,6 +44,34 @@ return Application::configure(basePath: dirname(__DIR__))
);
}
if (($exception instanceof QueryException || $exception instanceof ConnectionException || $exception instanceof \PDOException)
&& ! $request->is('api/v1/simulation-drafts*')) {
$reference = (string) ($response->headers->get('X-Correlation-ID')
?? $request->attributes->get('correlation_id')
?? Str::uuid());
$response->setStatusCode(503);
$response->headers->set('Cache-Control', 'no-store');
if ($request->is('api/*') || $request->expectsJson()) {
$response->setContent(json_encode([
'message' => 'Serviço temporariamente indisponível. Tente novamente mais tarde.',
'reference' => $reference,
], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
$response->headers->set('Content-Type', 'application/json; charset=utf-8');
} else {
$response->setContent(view('errors.database-unavailable', ['reference' => $reference])->render());
$response->headers->set('Content-Type', 'text/html; charset=utf-8');
}
}
if ($request->is('api/v1/simulation-drafts*') && $response->isServerError()) {
$response->setContent(json_encode([
'message' => 'Não foi possível guardar ou recuperar o rascunho. Os dados existentes não foram apagados. Tente novamente mais tarde.',
'reference' => $response->headers->get('X-Correlation-ID'),
], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
$response->headers->set('Content-Type', 'application/json; charset=utf-8');
}
return $response;
});
})->create();