mirror of
https://github.com/SrIzan10/starters.git
synced 2026-05-01 11:05:16 +00:00
14 lines
321 B
TypeScript
14 lines
321 B
TypeScript
import { Ctx } from "blitz"
|
|
import db from "db"
|
|
|
|
export default async function getCurrentUser(_ = null, { session }: Ctx) {
|
|
if (!session.userId) return null
|
|
|
|
const user = await db.user.findFirst({
|
|
where: { id: session.userId },
|
|
select: { id: true, name: true, email: true, role: true },
|
|
})
|
|
|
|
return user
|
|
}
|