BREAKING: postgres + saas

This commit is contained in:
Vasily Zubarev
2025-04-03 13:07:54 +02:00
parent 54a892ddb0
commit f523b1f8ba
136 changed files with 3971 additions and 1563 deletions

35
models/users.ts Normal file
View File

@@ -0,0 +1,35 @@
import { prisma } from "@/lib/db"
import { Prisma } from "@prisma/client"
import { cache } from "react"
export const SELF_HOSTED_USER = {
email: "taxhacker@localhost",
name: "Self-Hosted Mode",
}
export const getSelfHostedUser = cache(async () => {
return await prisma.user.findFirst({
where: { email: SELF_HOSTED_USER.email },
})
})
export const createSelfHostedUser = cache(async () => {
return await prisma.user.upsert({
where: { email: SELF_HOSTED_USER.email },
update: SELF_HOSTED_USER,
create: SELF_HOSTED_USER,
})
})
export const getUserByEmail = cache(async (email: string) => {
return await prisma.user.findUnique({
where: { email },
})
})
export function updateUser(userId: string, data: Prisma.UserUpdateInput) {
return prisma.user.update({
where: { id: userId },
data,
})
}