<?php

use Illuminate\Support\Facades\Route;
use Modules\Routing\Http\Controllers\EvRouteController;
use Modules\Routing\Http\Controllers\PopularRouteController;

Route::prefix('api/v1')->middleware(['api', 'api.auth', 'throttle:api-read'])->group(function () {
    Route::post('/routes/search', [EvRouteController::class, 'search'])->name('routing.routes.search');
    Route::get('/routes/{route}', [EvRouteController::class, 'show'])->name('routing.routes.show');
    Route::get('/routes/{route}/pricing', [EvRouteController::class, 'pricing'])->name('routing.routes.pricing');
    Route::get('/routes/{route}/time-slots', [EvRouteController::class, 'timeSlots'])->name('routing.routes.time-slots');
});

// Popular Routes are curated marketing content, typically shown before the
// user logs in (like CMS pages), so this group skips api.auth —
// throttle:api-read still rate-limits it by IP.
Route::prefix('api/v1')->middleware(['api', 'throttle:api-read'])->group(function () {
    Route::get('/popular-routes', [PopularRouteController::class, 'index'])->name('routing.popular-routes.index');
});
