withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { $middleware->encryptCookies(except: ['appearance', 'sidebar_state']); $middleware->web(append: [ HandleAppearance::class, HandleInertiaRequests::class, AddLinkHeadersForPreloadedAssets::class, ]); }) ->withSchedule(function (Schedule $schedule) { $schedule->command('article:refresh') ->everyFifteenMinutes() ->when(function () { return \App\Models\Setting::isArticleProcessingEnabled() && \App\Models\Feed::where('is_active', true)->exists(); }) ->withoutOverlapping() ->onOneServer(); }) ->withExceptions(function (Exceptions $exceptions) { $exceptions->reportable(function (Throwable $e) { $level = match (true) { $e instanceof Error => \App\Enums\LogLevelEnum::CRITICAL, $e instanceof RuntimeException => \App\Enums\LogLevelEnum::ERROR, $e instanceof InvalidArgumentException => \App\Enums\LogLevelEnum::WARNING, default => \App\Enums\LogLevelEnum::ERROR, }; App\Events\ExceptionOccurred::dispatch( $e, $level, $e->getMessage(), [] ); }); })->create();