d2d.emegrendeles.hu/bootstrap/app.php
E98Developer c35e86f633 ADD EV3-461 Mary-Ker API váz: saját route-csoport, beszállítóhoz kötött token, unprocessed/setProcessed
- /api/v1/maryker/order/unprocessed és setProcessed, auth:sanctum + maryker:orders ability mögött
- a szűrés a token tulajdonosának supplier_id-jából jön, konfigurálható oldalméret
- APICallBackId az első lekéréskor generálódik és stabil; írás toBase()-en (nincs updated_by szivárgás)
- setProcessed: kötelező, validált tömb, 422 hibás bemenetre
- maryker:api-token parancs szerepkör nélküli API-felhasználóval
- 401 JSON a Mary-Ker útvonalakon (a Hooreyca-útvonalak viselkedése változatlan)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 07:56:44 +02:00

73 lines
3.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
$middleware->alias([
'abilities' => \Laravel\Sanctum\Http\Middleware\CheckAbilities::class,
'ability' => \Laravel\Sanctum\Http\Middleware\CheckForAnyAbility::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
// Mary-Ker API (EV3-461): Accept fejléc nélkül is JSON hibaválasz, és a hitelesítési hiba 401 marad
// (a Hooreyca-útvonalakra ez szándékosan nem terjed ki, ld. a jegy backlogját).
$maryKerApi = fn (Request $request) => $request->is('api/v1/maryker/*');
$exceptions->shouldRenderJsonWhen(fn (Request $request, Throwable $e) => $maryKerApi($request) || $request->expectsJson());
// AJAX kérések esetén mindig JSON választ adunk, egyedi referencia kóddal
$exceptions->renderable(function (Throwable $e, Request $request) use ($maryKerApi) {
if ($e instanceof AuthenticationException && $maryKerApi($request)) {
return null;
}
if ($request->ajax() || $request->wantsJson() || $maryKerApi($request)) {
// Validációs hibákat nem piszkáljuk – azokat a Laravel alapból kezeli
if ($e instanceof ValidationException) {
return null;
}
// Egyedi referencia kód generálása
$errorRef = 'ERR-' . now()->format('ymdHis') . '-' . strtoupper(Str::random(6));
// Teljes technikai részlet a logba
\Log::error("[$errorRef] Unhandled exception", [
'error_ref' => $errorRef,
'message' => $e->getMessage(),
'exception' => get_class($e),
'file' => $e->getFile(),
'line' => $e->getLine(),
'url' => $request->fullUrl(),
'method' => $request->method(),
'user_id' => auth()->id(),
'input' => $request->except(['current_password', 'password', 'password_confirmation']),
'trace' => $e->getTraceAsString(),
]);
$statusCode = method_exists($e, 'getStatusCode')
? $e->getStatusCode()
: 500;
return response()->json([
'success' => false,
'error_ref' => $errorRef,
'message' => "Váratlan hiba történt. Hivatkozási kód: $errorRef",
], $statusCode);
}
return null;
});
})->create();