20 lines
363 B
TypeScript
20 lines
363 B
TypeScript
import { auth } from '@clerk/nextjs/server';
|
|
|
|
import { db } from '../prisma-client';
|
|
|
|
export async function getCurrentUser() {
|
|
const session = auth();
|
|
if (!session.userId) {
|
|
return null;
|
|
}
|
|
return getUserById(session.userId);
|
|
}
|
|
|
|
export async function getUserById(id: string) {
|
|
return db.user.findUniqueOrThrow({
|
|
where: {
|
|
id,
|
|
},
|
|
});
|
|
}
|