mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Port the stateless POST /api/meta-extraction endpoint from the dev branch onto current main. Extracts title/price/image from a product URL without persisting anything, auto-matching a store by domain and accepting an optional store override to test custom scrape strategies. The service is reimplemented against main's current ScrapeUrl/Store APIs (uses the existing domainFilter scope rather than dev's findByDomain helper chain) so it stays decoupled from dev's competing scraper refactor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
796 B
PHP
31 lines
796 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\MetaExtractionRequest;
|
|
use App\Http\Resources\MetaExtractionResource;
|
|
use App\Services\MetaExtractionService;
|
|
use Dedoc\Scramble\Attributes\Group;
|
|
|
|
#[Group('MetaExtraction')]
|
|
class MetaExtractionController extends Controller
|
|
{
|
|
public function __construct(
|
|
protected MetaExtractionService $metaExtractionService,
|
|
) {}
|
|
|
|
/**
|
|
* Extract meta data from a URL
|
|
*/
|
|
public function __invoke(MetaExtractionRequest $request): MetaExtractionResource
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
return new MetaExtractionResource($this->metaExtractionService->extract(
|
|
$validated['url'],
|
|
$validated['store'] ?? [],
|
|
));
|
|
}
|
|
}
|