mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-24 16:11:53 -05:00
Co-authored-by: Bereket Engida <86073083+Bekacru@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
38 lines
828 B
TypeScript
38 lines
828 B
TypeScript
import { submitFeedbackToAnalytics } from "@/lib/inkeep-analytics";
|
|
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export const runtime = "edge";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
const { messageId, type, reasons } = await req.json();
|
|
|
|
if (!messageId || !type) {
|
|
return NextResponse.json(
|
|
{ error: "messageId and type are required" },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
if (type !== "positive" && type !== "negative") {
|
|
return NextResponse.json(
|
|
{ error: "type must be 'positive' or 'negative'" },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
const result = await submitFeedbackToAnalytics({
|
|
messageId,
|
|
type,
|
|
reasons,
|
|
});
|
|
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: "Failed to submit feedback" },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
}
|