22 lines
453 B
TypeScript
22 lines
453 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getServerSession } from "../auth/[...nextauth]/auth";
|
|
import { prisma } from "@repo/db";
|
|
|
|
export const GET = async (req: NextRequest) => {
|
|
const session = await getServerSession();
|
|
if (!session) {
|
|
return {
|
|
status: 401,
|
|
body: "Unauthorized",
|
|
};
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: {
|
|
id: session.user.id,
|
|
},
|
|
});
|
|
|
|
return NextResponse.json(user);
|
|
};
|