import { upsertStreak } from "../../db/streak";

/** POST /api/streak – Streak starten oder reaktivieren */
export default defineEventHandler(async (event) => {
  const user = await requireUser(event);
  const body = await readBody(event);
  return upsertStreak(user.id, {
    avgMonthlySavings: body?.avgMonthlySavings,
    startDate: body?.startDate ?? null,
  });
});
