Update
This commit is contained in:
49
routes/api.php
Normal file
49
routes/api.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Api\CrawlController;
|
||||
use App\Http\Controllers\Api\ShotController;
|
||||
use Illuminate\Http\Request;
|
||||
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. Make something great!
|
||||
|
|
||||
*/
|
||||
|
||||
// File serving endpoints (no auth required for direct file access)
|
||||
Route::get('crawl/{uuid}.html', [CrawlController::class, 'serve'])->name('api.crawl.serve');
|
||||
Route::get('shot/{uuid}.webp', [ShotController::class, 'serve'])->name('api.shot.serve');
|
||||
|
||||
// All other API routes require Sanctum authentication
|
||||
Route::middleware(['auth:sanctum'])->group(function () {
|
||||
|
||||
// Crawl endpoints
|
||||
Route::prefix('crawl')->group(function () {
|
||||
Route::post('/', [CrawlController::class, 'crawl'])->name('api.crawl.create');
|
||||
Route::get('/{uuid}', [CrawlController::class, 'status'])->name('api.crawl.status');
|
||||
Route::get('/', [CrawlController::class, 'index'])->name('api.crawl.index'); // Optional: list all crawl jobs
|
||||
});
|
||||
|
||||
// Screenshot endpoints
|
||||
Route::prefix('shot')->group(function () {
|
||||
Route::post('/', [ShotController::class, 'shot'])->name('api.shot.create');
|
||||
Route::get('/{uuid}', [ShotController::class, 'status'])->name('api.shot.status');
|
||||
Route::get('/', [ShotController::class, 'index'])->name('api.shot.index'); // Optional: list all screenshot jobs
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Health check endpoint (no auth required)
|
||||
Route::get('/health', function () {
|
||||
return response()->json([
|
||||
'status' => 'healthy',
|
||||
'timestamp' => now()->toISOString(),
|
||||
'service' => 'crawlshot'
|
||||
]);
|
||||
})->name('api.health');
|
||||
Reference in New Issue
Block a user