Files
stats/packages/db/src/services/user.service.ts
Carl-Gerhard Lindesvärd 1fc64ef1f9 throw if user not found
2024-06-16 21:24:44 +02:00

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,
},
});
}