File size: 792 Bytes
da957b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { getAnnotations } from '../../../utils/storage.js';

export async function GET(request) {
    try {
        const { searchParams } = new URL(request.url);
        const docIndex = searchParams.get('document_index');

        const filter = docIndex !== null ? parseInt(docIndex, 10) : null;
        const annotations = await getAnnotations(filter);

        return new Response(JSON.stringify(annotations), {
            status: 200,
            headers: { 'Content-Type': 'application/json' }
        });
    } catch (error) {
        console.error("Error fetching annotations:", error);
        return new Response(
            JSON.stringify({ error: "Failed to fetch annotations" }),
            { status: 500, headers: { 'Content-Type': 'application/json' } }
        );
    }
}