UNPKG

@tayar/email

Version:

A simple email package for Tayar architecture

64 lines (62 loc) 2.37 kB
"use strict"; 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); // src/index.ts var src_exports = {}; __export(src_exports, { sendResetPasswordEmail: () => sendResetPasswordEmail }); module.exports = __toCommonJS(src_exports); // src/sendResetPasswordEmail.ts var import_config = require("@tayar/config"); var import_resend = require("resend"); async function sendResetPasswordEmail({ to, subject, resetURL }) { try { const config = (0, import_config.getConfig)(); if (!config || !config.resendToken) { throw new Error("Configuration not found"); } const resend = new import_resend.Resend(config.resendToken); const { data, error } = await resend.emails.send({ from: "contact@sikka.io", to, subject, text: "From sikka.io", html: `<p>You are receiving this because you (or someone else) have requested the reset of the password for your account.</p> <p>Please click on the following link, or paste this into your browser to complete the process:</p> <p><a href="${resetURL}">Reset Password</a></p> <p>If you did not request this, please ignore this email and your password will remain unchanged.</p>` }); if (error) { console.error("Error sending email: \u274C\u274C\u274C ", error); } if (data) console.log("Email sent: \u{1F601}\u{1F601}\u{1F601}", data); } catch (error) { console.error("Error sending email:\u274C\u274C\u274C", error); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { sendResetPasswordEmail }); //# sourceMappingURL=index.js.map