<?php

use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\PredictionController;
use App\Http\Controllers\Api\StationController;
use App\Http\Controllers\Api\StatsController;
use App\Http\Middleware\VerifyApiKey;
use Illuminate\Support\Facades\Route;

// Public endpoints (no API key required)
Route::post('/auth/register', [AuthController::class, 'register']);
Route::post('/auth/login', [AuthController::class, 'login']);

// Protected endpoints (API key required)
Route::middleware(['throttle:60,1', VerifyApiKey::class])->group(function (): void {
    Route::get('/stations', [StationController::class, 'index']);
    Route::get('/stats/searches', [StatsController::class, 'searches']);
    Route::get('/prediction', [PredictionController::class, 'index']);
});

// Sanctum-authenticated endpoints
Route::middleware('auth:sanctum')->group(function (): void {
    Route::get('/auth/me', [AuthController::class, 'me']);
    Route::post('/auth/logout', [AuthController::class, 'logout']);
});
