<?php

use App\Http\Controllers\AuthController;
use App\Http\Controllers\ListingController;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->group(function (): void {
    Route::get('health', fn (): JsonResponse => response()->json([
        'status' => 'ok',
        'service' => 'encostay-api',
        'timestamp' => now()->toIso8601String(),
    ]));

    Route::prefix('auth')->group(function (): void {
        Route::post('register', [AuthController::class, 'register'])->middleware('throttle:10,1');
        Route::post('login', [AuthController::class, 'login'])->middleware('throttle:10,1');

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

    Route::get('listings', [ListingController::class, 'index']);
    Route::get('listings/featured', [ListingController::class, 'featured']);
    Route::get('listings/{id}', [ListingController::class, 'show'])->whereUuid('id');
});