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.
72 lines (70 loc) • 2.36 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// lib/adapters/mail/ConsoleMailProvider.ts
var ConsoleMailProvider_exports = {};
__export(ConsoleMailProvider_exports, {
ConsoleMailProvider: () => ConsoleMailProvider
});
module.exports = __toCommonJS(ConsoleMailProvider_exports);
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();
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ConsoleMailProvider
});