feat!: upgrade to laravel-apiroute v2.0 with config-based versioning
- Update composer.json to require grazulex/laravel-apiroute ^2.0 - Add versions config to config/apiroute.php - Create routes/api/v1.php with version 1 routes - Update routes/api.php to remove imperative version declarations - Update README.md with new v2.x documentation BREAKING CHANGE: API versions are now declared in config/apiroute.php instead of routes/api.php
This commit is contained in:
@@ -1,29 +1,18 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Api\V1\AuthController;
|
||||
use Grazulex\ApiRoute\Facades\ApiRoute;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| API routes are versioned using grazulex/laravel-apiroute.
|
||||
| API routes are versioned using grazulex/laravel-apiroute v2.x.
|
||||
| Versions are defined in config/apiroute.php and route files are
|
||||
| located in routes/api/{version}.php
|
||||
|
|
||||
| Supports URI path, header, query, and Accept header detection.
|
||||
| See config/apiroute.php for configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
// Version 1 - Current stable version
|
||||
ApiRoute::version('v1', function () {
|
||||
// Public routes
|
||||
Route::post('register', [AuthController::class, 'register'])->name('api.v1.register');
|
||||
Route::post('login', [AuthController::class, 'login'])->name('api.v1.login');
|
||||
|
||||
// Protected routes
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('logout', [AuthController::class, 'logout'])->name('api.v1.logout');
|
||||
Route::get('me', [AuthController::class, 'me'])->name('api.v1.me');
|
||||
});
|
||||
})->current();
|
||||
// Routes are now loaded automatically from config/apiroute.php
|
||||
// See routes/api/v1.php for version 1 routes
|
||||
|
||||
Reference in New Issue
Block a user