11import { NextRequest , NextResponse } from "next/server" ;
22import { apiClient } from "@/app/lib/apiClient" ;
3- import fs from "fs" ;
4- import path from "path" ;
5-
6- // Set to true to use mock data, false to use real backend
7- const USE_MOCK_DATA = false ;
8-
9- // === MOCK DATA (remove this section when no longer needed) ===
10- const MOCK_FILE_MAP : Record < string , string > = {
11- "44" : "evaluation-sample-2.json" ,
12- "2" : "evaluation-sample-2.json" ,
13- "10" : "evaluation-sample-3.json" ,
14- "3" : "evaluation-sample-3.json" ,
15- } ;
16-
17- function getMockEvaluation ( id : string ) : NextResponse {
18- const mockFileName = MOCK_FILE_MAP [ id ] || "evaluation-sample-1.json" ;
19- const filePath = path . join (
20- process . cwd ( ) ,
21- "public" ,
22- "mock-data" ,
23- mockFileName ,
24- ) ;
25-
26- try {
27- const fileContent = fs . readFileSync ( filePath , "utf-8" ) ;
28- const mockData = JSON . parse ( fileContent ) ;
29- return NextResponse . json ( mockData , { status : 200 } ) ;
30- } catch ( err ) {
31- console . error ( "Error reading mock data:" , err ) ;
32- return NextResponse . json (
33- {
34- error : "Mock data not found" ,
35- details : err instanceof Error ? err . message : String ( err ) ,
36- } ,
37- { status : 404 } ,
38- ) ;
39- }
40- }
413
424/**
435 * GET /api/evaluations/[id]
@@ -50,10 +12,6 @@ export async function GET(
5012 try {
5113 const { id } = await params ;
5214
53- if ( USE_MOCK_DATA ) {
54- return getMockEvaluation ( id ) ;
55- }
56-
5715 const searchParams = request . nextUrl . searchParams ;
5816 const exportFormat = searchParams . get ( "export_format" ) || "row" ;
5917 const resyncScore = searchParams . get ( "resync_score" ) || "false" ;
0 commit comments