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

@@ -0,0 +1,43 @@
import { NextRequest, NextResponse } from 'next/server';
const API_BASE = process.env.API_URL || 'http://localhost:8001';
/**
* GET /api/pipelines/reviewiq/reviews/[reviewId]
* Proxy to backend for fetching a full review with all its spans.
*/
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ reviewId: string }> }
) {
const { reviewId } = await params;
const { searchParams } = new URL(request.url);
const source = searchParams.get('source') || 'google';
try {
const url = `${API_BASE}/api/pipelines/reviewiq/reviews/${encodeURIComponent(reviewId)}?source=${encodeURIComponent(source)}`;
const response = await fetch(url, {
headers: {
'Content-Type': 'application/json',
},
});
if (!response.ok) {
const error = await response.text();
return NextResponse.json(
{ error: `Backend error: ${error}` },
{ status: response.status }
);
}
const data = await response.json();
return NextResponse.json(data);
} catch (error) {
console.error('Error fetching review:', error);
return NextResponse.json(
{ error: 'Failed to fetch review' },
{ status: 500 }
);
}
}