-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract sending email, to allow for other email services #11
base: master
Are you sure you want to change the base?
Conversation
mykeels
commented
Aug 10, 2021
- mailgun
- sendgrid
Someone is attempting to deploy a commit to a Personal Account owned by @epleaner on Vercel. @epleaner first needs to authorize it. |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/epleaner/emotions-wheel/DUJALNzt3SCvUczgJSuHAGz4TxMH |
const emailFrom = process.env.MAIL_FROM; | ||
const url = process.env.MAIL_HOST_URL; | ||
|
||
const ignore = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fn does not need to be async
const ignore = async () => { | ||
console.warn("Unrecognized mail service", service); | ||
}; | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline between fns
const params = { | ||
from: emailFrom, | ||
...options, | ||
...(options.dynamic_template_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find this destructuring ternary pattern quite unreadable
sgMail.setApiKey(apiKey); | ||
return sgMail.send({ from: emailFrom, ...options }); | ||
}, | ||
}[service && service.toLowerCase()] || ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is going on in this line?
import crypto from 'crypto'; | ||
import { hoursFromNow } from '@helpers/apiHelpers'; | ||
import normalizeEmail from 'validator/lib/normalizeEmail'; | ||
|
||
sgMail.setApiKey(process.env.SENDGRID_API_KEY); | ||
import { sendEmail } from './sendEmail'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use absolute imports
import crypto from 'crypto'; | ||
import nextConnect from 'next-connect'; | ||
|
||
import database from '@middleware/database'; | ||
import { minutesFromNow } from '@helpers/apiHelpers'; | ||
|
||
sgMail.setApiKey(process.env.SENDGRID_API_KEY); | ||
import { sendEmail } from '../../../../helpers/apiHelpers/sendEmail'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use absolute imports
Hi @mykeels , thanks for contributing! Wondering why you closed this PR before it was reviewed and merged? |