40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\Api\AuthController;
|
|
use App\Http\Controllers\Api\PostController;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| API Routes
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here is where you can register API routes for your application. These
|
|
| routes are loaded by the RouteServiceProvider and all of them will
|
|
| be assigned to the "api" middleware group.
|
|
|
|
|
*/
|
|
|
|
// Swagger Documentation
|
|
Route::get('/docs', function () {
|
|
return redirect()->to('/docs/index.html');
|
|
});
|
|
|
|
// Public routes
|
|
Route::post('/register', [AuthController::class, 'register'])->name('api.register');
|
|
Route::post('/login', [AuthController::class, 'login'])->name('api.login');
|
|
|
|
// Protected routes
|
|
Route::middleware('auth:sanctum')->group(function () {
|
|
// Auth
|
|
Route::post('/logout', [AuthController::class, 'logout'])->name('api.logout');
|
|
Route::get('/user', [AuthController::class, 'user'])->name('api.user');
|
|
|
|
// Posts
|
|
Route::get('/posts', [PostController::class, 'index'])->name('api.posts.index');
|
|
Route::post('/posts', [PostController::class, 'store'])->name('api.posts.store');
|
|
Route::get('/posts/{post}', [PostController::class, 'show'])->name('api.posts.show');
|
|
Route::put('/posts/{post}', [PostController::class, 'update'])->name('api.posts.update');
|
|
Route::delete('/posts/{post}', [PostController::class, 'destroy'])->name('api.posts.destroy');
|
|
});
|