Initial commit - WhyRating Engine (Google Reviews Scraper)

This commit is contained in:
Alejandro Gutiérrez
2026-02-02 18:19:00 +00:00
parent 0543a08242
commit 2206ddeff2
136 changed files with 51138 additions and 855 deletions

View File

@@ -1,16 +1,38 @@
import { NextRequest, NextResponse } from 'next/server';
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8001';
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { url, business_name, business_address, rating_snapshot, total_reviews_snapshot, scraper_version } = body;
const { url, business_name, business_address, rating_snapshot, total_reviews_snapshot, scraper_version, session_id, browser_fingerprint, geolocation } = body;
if (!url) {
return NextResponse.json({ error: 'URL is required' }, { status: 400 });
}
// Build metadata object
const metadata: Record<string, unknown> = {
business_name,
business_address,
rating_snapshot,
total_reviews_snapshot,
scraper_version, // Store in metadata for job tracking
};
// Include session_id for browser reuse (session handoff from validation)
if (session_id) {
metadata.session_id = session_id;
}
// Include browser fingerprint if provided
if (browser_fingerprint) {
metadata.browser_fingerprint = browser_fingerprint;
}
if (geolocation) {
metadata.geolocation = geolocation;
}
// Call the containerized scraper API with business metadata and version
const response = await fetch(`${API_BASE_URL}/scrape`, {
method: 'POST',
@@ -18,13 +40,8 @@ export async function POST(request: NextRequest) {
body: JSON.stringify({
url,
scraper_version, // Pass version to backend for routing
metadata: {
business_name,
business_address,
rating_snapshot,
total_reviews_snapshot,
scraper_version, // Also store in metadata for job tracking
},
session_id, // Pass session_id for browser reuse
metadata,
}),
});