From: Luigi Pinca Date: Sat, 6 Sep 2025 12:54:50 +0000 (+0200) Subject: replaced Sendgrid with Resend X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=94a63fb63304c14836dd14ad43af6013ac27d645;p=binbsis50.git replaced Sendgrid with Resend --- diff --git a/lib/email/mailer.js b/lib/email/mailer.js index 8e5d96d..d632039 100644 --- a/lib/email/mailer.js +++ b/lib/email/mailer.js @@ -2,7 +2,7 @@ const fs = require('fs'); const pug = require('pug'); -const sendgrid = require('@sendgrid/mail'); +const { Resend } = require('resend'); const texttemplate = fs.readFileSync(__dirname + '/template.txt', 'utf-8'); @@ -20,21 +20,23 @@ const plaintextMessage = function(token) { return texttemplate.replace(//, token); }; -sendgrid.setApiKey(process.env.SENDGRID_API_KEY); +const resend = new Resend(process.env.RESEND_API_KEY); /** * Send the reset password email. */ exports.sendEmail = function(to, token, callback) { - sendgrid.send( - { + resend.emails + .send({ from: 'binb ', to: to, subject: 'binb password recovery', html: HTMLMessage({ token: token }), text: plaintextMessage(token) - }, - callback - ); + }) + .then(function({ error }) { + callback(error); + }) + .catch(callback); }; diff --git a/package.json b/package.json index 8b8139b..632fc80 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "node": ">=16.0.0" }, "dependencies": { - "@sendgrid/mail": "^7.3.0", "async": "^3.1.1", "body-parser": "^1.18.3", "canvas": "^2.4.1", @@ -25,11 +24,12 @@ "express": "^4.16.4", "express-session": "^1.16.1", "forwarded-for": "^1.0.1", + "ioredis": "^5.3.2", "primus": "^8.0.1", "primus-emitter": "^3.1.1", "primus-rooms": "^3.4.1", "pug": "^3.0.2", - "ioredis": "^5.3.2", + "resend": "^6.0.2", "serve-favicon": "^2.5.0", "uglify-js": "^3.5.4", "ws": "^8.13.0"