-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://edu.duthanhduoc.com/learn/Nest.js-Super?lessonId=726 #107
Comments
Anh ơi em có 1 câu hỏi là vd bên controller anh khai báo body: RegisterBodyDTO bên services anh sao không khai báo lun là body: RegisterBodyDTO mà sao anh lại phải body: RegisterBodyType |
2 lý do:
Đây là ví dụ file import { Injectable } from '@nestjs/common'
import { RegisterBodyType, VerificationCodeType } from 'src/routes/auth/auth.model'
import { TypeOfVerificationCodeType } from 'src/shared/constants/auth.constant'
import { UserType } from 'src/shared/models/shared-user.model'
import { PrismaService } from 'src/shared/services/prisma.service'
@Injectable()
export class AuthRepository {
constructor(private readonly prismaService: PrismaService) {}
async createUser(
user: Omit<RegisterBodyType, 'confirmPassword' | 'code'> & Pick<UserType, 'roleId'>,
): Promise<Omit<UserType, 'password' | 'totpSecret'>> {
return this.prismaService.user.create({
data: user,
omit: {
password: true,
totpSecret: true,
},
})
}
async createVerificationCode(
payload: Pick<VerificationCodeType, 'email' | 'type' | 'code' | 'expiresAt'>,
): Promise<VerificationCodeType> {
return this.prismaService.verificationCode.upsert({
where: {
email: payload.email,
},
create: payload,
update: {
code: payload.code,
expiresAt: payload.expiresAt,
},
})
}
async findUniqueVerificationCode(
uniqueValue:
| { email: string }
| { id: number }
| {
email: string
code: string
type: TypeOfVerificationCodeType
},
): Promise<VerificationCodeType | null> {
return this.prismaService.verificationCode.findUnique({
where: uniqueValue,
})
}
} |
Khu vực học tập | Được Edu
Được chỉ cung cấp các khóa học lập trình online chất lượng, nói không với khóa lởm!
https://edu.duthanhduoc.com/learn/Nest.js-Super?lessonId=726
The text was updated successfully, but these errors were encountered: