52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
|
|
return Application::configure(basePath: dirname(__DIR__))
|
|
->withRouting(
|
|
api: __DIR__ . '/../routes/api.php',
|
|
health: '/up',
|
|
)
|
|
->withMiddleware(function (Middleware $middleware) {
|
|
// Register custom middleware aliases
|
|
$middleware->alias([
|
|
'hmac.auth' => \App\Http\Middleware\HmacAuthMiddleware::class,
|
|
'jwt.auth' => \App\Http\Middleware\JwtAuthMiddleware::class,
|
|
'admin' => \App\Http\Middleware\AdminMiddleware::class,
|
|
]);
|
|
|
|
// Global API middleware
|
|
$middleware->api(prepend: [
|
|
\Illuminate\Http\Middleware\HandleCors::class,
|
|
'throttle:120,1',
|
|
]);
|
|
})
|
|
->withExceptions(function (Exceptions $exceptions) {
|
|
$exceptions->render(function (\Throwable $e) {
|
|
\Log::error('Unhandled Exception', [
|
|
'message' => $e->getMessage(),
|
|
'file' => $e->getFile(),
|
|
'line' => $e->getLine(),
|
|
'trace' => $e->getTraceAsString(),
|
|
]);
|
|
|
|
if (config('app.debug')) {
|
|
return response()->json([
|
|
'status' => 'failure',
|
|
'message' => 'DEBUG ERROR: ' . $e->getMessage(),
|
|
'file' => $e->getFile(),
|
|
'line' => $e->getLine()
|
|
], 500);
|
|
}
|
|
|
|
return response()->json([
|
|
'status' => 'failure',
|
|
'message' => 'Internal server error',
|
|
], 500);
|
|
});
|
|
})
|
|
->create()
|
|
->useEnvironmentPath('/home/intaleq-api/env');
|