<?php

use App\Http\Controllers\AuthController;
use App\Http\Controllers\HealthController;
use App\Http\Controllers\PasswordController;
use App\Http\Controllers\UserController;
use App\Http\Middleware\Authenticate;

$router = $this->router;

$router->get('/', [HealthController::class, 'check']);
$router->get('/health', [HealthController::class, 'check']);
$router->get('/public-key', [AuthController::class, 'publicKey']);
$router->get('/.well-known/jwks.json', [AuthController::class, 'jwks']);

$router->post('/v1/auth/register', [AuthController::class, 'register']);
$router->post('/v1/auth/login', [AuthController::class, 'login']);
$router->post('/v1/auth/refresh', [AuthController::class, 'refresh']);
$router->post('/v1/auth/logout', [AuthController::class, 'logout'], [Authenticate::class]);
$router->post('/v1/auth/validate-token', [AuthController::class, 'validateToken']);
$router->post('/v1/auth/forgot-password', [PasswordController::class, 'forgotPassword']);
$router->post('/v1/auth/reset-password', [PasswordController::class, 'resetPassword']);
$router->get('/v1/user/me', [UserController::class, 'me'], [Authenticate::class]);
$router->get('/v1/auth/roles', [UserController::class, 'roles']);
$router->get('/v1/auth/statuses', [UserController::class, 'statuses']);

// Backward-compatible routes used by existing frontend/tests.
$router->post('/api/auth/register', [AuthController::class, 'register']);
$router->post('/api/auth/login', [AuthController::class, 'login']);
$router->post('/api/auth/validate-token', [AuthController::class, 'validateToken']);
$router->get('/api/auth/roles', [UserController::class, 'roles']);
$router->get('/api/auth/statuses', [UserController::class, 'statuses']);
