Files
football-next/app/api/user/profile/route.ts
2026-05-13 15:46:27 +03:30

15 lines
489 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { getApiUser } from "@/lib/apiAuth";
export async function PUT(req: NextRequest) {
const apiUser = await getApiUser(req);
if (!apiUser) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const { name } = await req.json();
const user = await db.user.update({
where: { id: apiUser.id },
data: { name },
});
return NextResponse.json({ name: user.name });
}