Study/src/app/api/settings/llm-instructions/route.ts
Elijah b7ce314f01
Some checks failed
Automated Container Build / build-and-push (push) Failing after 7s
Initial working commit
2026-06-27 19:19:38 -07:00

31 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import * as settingsService from "@/services/settingsService";
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const type = searchParams.get("type") as "flashcards" | "quizzes" || "flashcards";
const instructions = await settingsService.getLlmInstructions(type);
return NextResponse.json({ value: instructions });
}
export async function PATCH(request: NextRequest) {
const { searchParams } = new URL(request.url);
const type = searchParams.get("type") as "flashcards" | "quizzes" || "flashcards";
const body = await request.json().catch(() => null);
if (!body || typeof body.value !== "string") {
return NextResponse.json(
{ error: "value is required" },
{ status: 400 }
);
}
if (body.value === "__RESET__") {
await settingsService.resetLlmInstructions(type);
const instructions = await settingsService.getLlmInstructions(type);
return NextResponse.json({ value: instructions });
}
await settingsService.updateLlmInstructions(type, body.value);
return NextResponse.json({ value: body.value });
}