-web-service

This commit is contained in:
2025-11-11 15:11:56 +07:00
parent 9ad26fa5ef
commit fcf59ce5db
21 changed files with 537 additions and 253 deletions

View File

@@ -0,0 +1,17 @@
import { generateOTP } from '../utils/otp.js'
import { sendMockOtpMail } from '../utils/mailer.js'
import { saveOtp, verifyOtp, removeOtp } from '../utils/redis.js'
import { sendError } from '../utils/response.js'
export class OtpService {
async sendOtp(email) {
try {
const otp = generateOTP()
await saveOtp(email, otp)
await sendMockOtpMail(email, otp)
return { email, otp}
} catch (error) {
return sendError('ไม่สามารถส่ง OTP ได้', 'Failed to send OTP')
}
}
}