UNPKG

aegis-auth

Version:

A credentials-based auth solution for Next.js (and other Node projects) with IP rate-limiting, account lockouts, and sessions in DB.

38 lines 1.48 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { Resend } from "resend"; export async function sendEmail(options) { var _a; const { config } = options, emailOptions = __rest(options, ["config"]); if (!config.email || !config.email.resendApiKey) { throw new Error("Resend API key is not configured in your email settings."); } const resend = new Resend(config.email.resendApiKey); try { const from = (_a = emailOptions.from) !== null && _a !== void 0 ? _a : config.email.from; if (!from) { throw new Error("No from email is setup."); } const data = await resend.emails.send({ from, to: Array.isArray(emailOptions.to) ? emailOptions.to : [emailOptions.to], subject: emailOptions.subject, html: emailOptions.html, }); return data; } catch (error) { config.logger.error("Failed to send email", { error }); throw error; } } //# sourceMappingURL=sendEmail.js.map