SPB Git

Repository Public

route.ts 1.3 KB 30 lines typescript

1// Auteur : Simon-Pierre Boucher — contact@spboucher.ai2// Mon KA — confidentialité (session hub requise).3//   POST { personalization? | history? | recos? : bool,4//          clear_history?: true, reset?: true }5// « reset » efface le journal, le profil appris, les corrections et les6// éléments masqués — repart de zéro (les favoris et recherches restent).7import { NextRequest, NextResponse } from "next/server";8import { getSessionUser } from "@/lib/auth";9import {10  setPrivacy, privacyOf, clearHistory, resetPersonalization,11} from "@/lib/kaid-data";1213export async function POST(req: NextRequest) {14  const user = await getSessionUser();15  if (!user)16    return NextResponse.json({ error: "non connecté" }, { status: 401 });17  const body = (await req.json().catch(() => ({}))) as Record<string, unknown>;1819  if (body.reset === true) resetPersonalization(user.id);20  else if (body.clear_history === true) clearHistory(user.id);21  else22    setPrivacy(user.id, {23      personalization:24        typeof body.personalization === "boolean" ? body.personalization : undefined,25      history: typeof body.history === "boolean" ? body.history : undefined,26      recos: typeof body.recos === "boolean" ? body.recos : undefined,27    });28  return NextResponse.json({ ok: true, privacy: privacyOf(user.id) });29}30
Files main
Menu

Theme