+server.ts

 1import { json } from '@sveltejs/kit';
 2import { addContextFile, removeContextFile, getContextFiles } from '$lib/server/review-store';
 3import type { RequestHandler } from './$types.ts';
 4
 5export const GET: RequestHandler = async () => {
 6	return json({ files: getContextFiles() });
 7};
 8
 9export const POST: RequestHandler = async ({ request }) => {
10	const body = await request.json();
11	const { path, action } = body;
12
13	if (!path) {
14		return json({ error: 'Missing path' }, { status: 400 });
15	}
16
17	if (action === 'remove') {
18		removeContextFile(path);
19	} else {
20		addContextFile(path);
21	}
22
23	return json({ files: getContextFiles() });
24};