UNPKG

waitlist-mailer

Version:

Modern, modular TypeScript library for managing waitlists with pluggable storage and mail providers. Supports MongoDB, SQL databases, and custom adapters with zero required dependencies for basic usage.

48 lines (46 loc) 1.29 kB
// lib/adapters/mail/ConsoleMailProvider.ts var ConsoleMailProvider = class { constructor(verbose = true) { this.verbose = verbose; } /** * Output a confirmation email to console. * @param email - Recipient email address * @param context - Email context * @returns Always returns true (successful "send") */ async sendConfirmation(email, context) { const timestamp = (/* @__PURE__ */ new Date()).toISOString(); const subject = this.buildSubject(context); const body = this.buildBody(context); console.log(` ${"=".repeat(60)}`); console.log(`[EMAIL SENT] ${timestamp}`); console.log(`To: ${email}`); console.log(`Subject: ${subject}`); if (this.verbose) { console.log(` Context:`); console.log(JSON.stringify(context, null, 2)); console.log(` Body:`); console.log(body); } console.log(`${"=".repeat(60)} `); return true; } buildSubject(context) { return context.subject || `Welcome to ${context.companyName || "our platform"}`; } buildBody(context) { return context.customHtml || ` Thank you for joining ${context.companyName || "our platform"}! Email: ${context.email} ${context.customUrl ? `Link: ${context.customUrl}` : ""} `.trim(); } }; export { ConsoleMailProvider };