<?php

use App\Http\Middleware\ApiMiddleware;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Support\Facades\Route;
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
        then: function () {

            // Route::prefix('api')
            //     ->middleware('api')
            //     ->namespace($this->namespace)
            //     ->group(base_path('routes/api.php'));

            // Route::middleware('web')
            //     ->namespace($this->namespace)
            //     ->group(base_path('routes/web.php'));
            
            // Route::prefix('api/v2')
            //     ->middleware('api')
            //     ->group(base_path('routes/api/v2/index.php'));


        }
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'auth' => \App\Http\Middleware\Authenticate::class,
            'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
            'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
            'can' => \Illuminate\Auth\Middleware\Authorize::class,
            'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
            'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
            'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
            'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
            'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
            'only_organizer' => \App\Http\Middleware\OrganizerMiddleware::class,
            'pos'    => \App\Http\Middleware\Pos::class,
            'scanner'    => \App\Http\Middleware\Scanner::class,
            'sub-organizer' => \App\Http\Middleware\SubOrganizer::class,
            'review' => \App\Http\Middleware\Review::class,
            'pos_user_only'    => \App\Http\Middleware\OnlyPos::class,
        ]);

        $middleware->api(prepend: [
            
        ]);

        $middleware->validateCsrfTokens(except: [
            '/checkout/razorpay/callback',
            '/checkout/paytm/callback',
            '/paystack/payment/callback',
            '/stripe/response',
            '/stripe/webhook',
            '/mercadopago/callback',
            '/flutterwave/callback',
            '/flutterwave/webhook',
            '/flutterwave/app-callback',
        
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();
