UNPKG

@tayar/email

Version:

A simple email package for Tayar architecture

1 lines 1.97 kB
{"version":3,"sources":["../src/sendResetPasswordEmail.ts"],"sourcesContent":["//@ts-ingore\nimport { getConfig } from \"@tayar/config\";\nimport { Resend } from \"resend\";\n\nimport { EmailParams } from \"./types\";\n\nexport async function sendResetPasswordEmail({\n to,\n subject,\n resetURL\n}: EmailParams) {\n try {\n const config = getConfig();\n if (!config || !config.resendToken) {\n throw new Error(\"Configuration not found\");\n }\n\n const resend = new Resend(config.resendToken);\n // Send the email\n const { data, error } = await resend.emails.send({\n from: \"contact@sikka.io\",\n to: to,\n subject: subject,\n text: \"From sikka.io\",\n html: `<p>You are receiving this because you (or someone else) have requested the reset of the password for your account.</p>\n <p>Please click on the following link, or paste this into your browser to complete the process:</p>\n <p><a href=\"${resetURL}\">Reset Password</a></p>\n <p>If you did not request this, please ignore this email and your password will remain unchanged.</p>`\n });\n\n if (error) {\n console.error(\"Error sending email: ❌❌❌ \", error);\n }\n if (data) console.log(\"Email sent: 😁😁😁\", data);\n } catch (error) {\n console.error(\"Error sending email:❌❌❌\", error);\n }\n}\n"],"mappings":";AACA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAIvB,eAAsB,uBAAuB;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AACF,GAAgB;AACd,MAAI;AACF,UAAM,SAAS,UAAU;AACzB,QAAI,CAAC,UAAU,CAAC,OAAO,aAAa;AAClC,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AAEA,UAAM,SAAS,IAAI,OAAO,OAAO,WAAW;AAE5C,UAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,OAAO,KAAK;AAAA,MAC/C,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA;AAAA,2BAEe,QAAQ;AAAA;AAAA,IAE/B,CAAC;AAED,QAAI,OAAO;AACT,cAAQ,MAAM,4CAA6B,KAAK;AAAA,IAClD;AACA,QAAI;AAAM,cAAQ,IAAI,2CAAsB,IAAI;AAAA,EAClD,SAAS,OAAO;AACd,YAAQ,MAAM,0CAA2B,KAAK;AAAA,EAChD;AACF;","names":[]}