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,6 +1,6 @@
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 GET(
request: NextRequest,

View File

@@ -1,6 +1,6 @@
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,

View File

@@ -1,6 +1,6 @@
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 GET(
request: NextRequest,

View File

@@ -1,6 +1,6 @@
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 GET(
request: NextRequest,

View File

@@ -1,6 +1,6 @@
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 GET(
request: NextRequest,

View File

@@ -1,6 +1,6 @@
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 GET(
request: NextRequest,

View File

@@ -0,0 +1,42 @@
import { NextRequest, NextResponse } from 'next/server';
const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:8001';
/**
* Proxy route for ReviewIQ analytics endpoint.
* GET /api/pipelines/reviewiq/analytics
*/
export async function GET(request: NextRequest) {
try {
// Forward query parameters
const searchParams = request.nextUrl.searchParams;
const queryString = searchParams.toString();
const url = `${API_BASE_URL}/api/pipelines/reviewiq/analytics${queryString ? `?${queryString}` : ''}`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
cache: 'no-store',
});
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
return NextResponse.json(
{ detail: errorData.detail || `Backend error: ${response.status}` },
{ status: response.status }
);
}
const data = await response.json();
return NextResponse.json(data);
} catch (error) {
console.error('ReviewIQ analytics proxy error:', error);
return NextResponse.json(
{ detail: 'Failed to fetch analytics data' },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,42 @@
import { NextRequest, NextResponse } from 'next/server';
const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:8001';
/**
* Proxy route for fetching spans related to an issue.
* GET /api/pipelines/reviewiq/issues/[issueId]/spans
*/
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ issueId: string }> }
) {
try {
const { issueId } = await params;
const url = `${API_BASE_URL}/api/pipelines/reviewiq/issues/${issueId}/spans`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
cache: 'no-store',
});
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
return NextResponse.json(
{ detail: errorData.detail || `Backend error: ${response.status}` },
{ status: response.status }
);
}
const data = await response.json();
return NextResponse.json(data);
} catch (error) {
console.error('Issue spans proxy error:', error);
return NextResponse.json(
{ detail: 'Failed to fetch issue spans' },
{ status: 500 }
);
}
}

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 }
);
}
}

View File

@@ -0,0 +1,42 @@
import { NextRequest, NextResponse } from 'next/server';
const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:8001';
/**
* Proxy route for ReviewIQ trends endpoint.
* GET /api/pipelines/reviewiq/trends
*/
export async function GET(request: NextRequest) {
try {
// Forward query parameters
const searchParams = request.nextUrl.searchParams;
const queryString = searchParams.toString();
const url = `${API_BASE_URL}/api/pipelines/reviewiq/trends${queryString ? `?${queryString}` : ''}`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
cache: 'no-store',
});
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
return NextResponse.json(
{ detail: errorData.detail || `Backend error: ${response.status}` },
{ status: response.status }
);
}
const data = await response.json();
return NextResponse.json(data);
} catch (error) {
console.error('ReviewIQ trends proxy error:', error);
return NextResponse.json(
{ detail: 'Failed to fetch trends data' },
{ status: 500 }
);
}
}

View File

@@ -1,6 +1,6 @@
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 GET(request: NextRequest) {
try {