(
userId: string,
email: string
)
| 28 | } |
| 29 | |
| 30 | async function generateEmailVerificationCode( |
| 31 | userId: string, |
| 32 | email: string |
| 33 | ): Promise<string> { |
| 34 | const code = generateRandomString(8, alphabet("0-9")); |
| 35 | await db.transaction(async (trx) => { |
| 36 | await trx |
| 37 | .delete(emailVerificationCodes) |
| 38 | .where(eq(emailVerificationCodes.userId, userId)); |
| 39 | |
| 40 | await trx.insert(emailVerificationCodes).values({ |
| 41 | userId, |
| 42 | email, |
| 43 | code, |
| 44 | expiresAt: createDate(new TimeSpan(15, "m")).getTime() |
| 45 | }); |
| 46 | }); |
| 47 | return code; |
| 48 | } |
no outgoing calls
no test coverage detected