57 lines
2.4 KiB
PHP
57 lines
2.4 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\Api\CrawlController;
|
|
use App\Http\Controllers\Api\ShotController;
|
|
use App\Http\Controllers\Api\WebhookErrorController;
|
|
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
|
|
});
|
|
|
|
// Webhook error endpoints
|
|
Route::prefix('webhook-errors')->group(function () {
|
|
Route::get('/', [WebhookErrorController::class, 'index'])->name('api.webhook-errors.index');
|
|
Route::post('/{uuid}/retry', [WebhookErrorController::class, 'retry'])->name('api.webhook-errors.retry');
|
|
Route::delete('/{uuid}/clear', [WebhookErrorController::class, 'clear'])->name('api.webhook-errors.clear');
|
|
});
|
|
|
|
});
|
|
|
|
// Health check endpoint (no auth required)
|
|
Route::get('/health', function () {
|
|
return response()->json([
|
|
'status' => 'healthy',
|
|
'timestamp' => now()->toISOString(),
|
|
'service' => 'crawlshot'
|
|
]);
|
|
})->name('api.health'); |