<?php

use Illuminate\Support\Facades\Route;
use Maestro\Core\Http\Controllers\AuthController;
use Maestro\Core\Http\Controllers\RoleController;
use Maestro\Core\Http\Controllers\UserController;

// Public
Route::post('auth/login', [AuthController::class, 'login'])
    ->middleware('throttle:10,1');

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

    Route::apiResource('users', UserController::class)
        ->middleware('permission:users.view');

    Route::get('roles', [RoleController::class, 'index'])
        ->middleware('permission:roles.view');
    Route::post('roles', [RoleController::class, 'store'])
        ->middleware('permission:roles.create');
    Route::put('roles/{role}', [RoleController::class, 'update'])
        ->middleware('permission:roles.edit');
    Route::delete('roles/{role}', [RoleController::class, 'destroy'])
        ->middleware('permission:roles.delete');
    Route::get('permissions', [RoleController::class, 'permissions'])
        ->middleware('permission:roles.view');
});
