// Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // Project: chat.spboucher.ai import { NextResponse, type NextRequest } from "next/server"; import { requireSession } from "@/lib/auth/guard"; import { setModelPref } from "@/lib/catalog"; export const runtime = "nodejs"; export async function POST(req: NextRequest) { const { unauthorized } = await requireSession(); if (unauthorized) return unauthorized; let body: { modelId?: string; favorite?: boolean; pinned?: boolean }; try { body = await req.json(); } catch { return NextResponse.json({ error: "Invalid request." }, { status: 400 }); } if (!body.modelId) { return NextResponse.json({ error: "modelId is required." }, { status: 400 }); } setModelPref(body.modelId, { favorite: body.favorite, pinned: body.pinned }); return NextResponse.json({ ok: true }); }