mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-28 20:04:26 +00:00
refactor(api): enforce layered architecture by moving db queries to core services
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
|
||||
export class UserService {
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
|
||||
async getUserById(id: string) {
|
||||
return this.prismaClient.user.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
|
||||
async createGuestUser(data: { name: string; email: string; guestEmail: string }) {
|
||||
return this.prismaClient.user.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
email: data.email,
|
||||
guestEmail: data.guestEmail,
|
||||
type: 'human',
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const userService = new UserService()
|
||||
Reference in New Issue
Block a user