import { logger } from "@platform/logger"; import { betterAuth } from "better-auth"; import { mongodbAdapter } from "better-auth/adapters/mongodb"; import { emailOTP } from "better-auth/plugins"; import { db } from "./database.ts"; export const auth = betterAuth({ database: mongodbAdapter(db.db), session: { cookieCache: { enabled: true, maxAge: 5 * 60, // Cache duration in seconds }, }, plugins: [ emailOTP({ async sendVerificationOTP({ email, otp, type }) { if (type === "sign-in") { logger.info({ email, otp, type }); } else if (type === "email-verification") { // Send the OTP for email verification } else { // Send the OTP for password reset } }, }), ], });