Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mykeels
Copy link

@mykeels mykeels commented Aug 10, 2021

  • mailgun
  • sendgrid

@vercel
Copy link

vercel bot commented Aug 10, 2021

Someone is attempting to deploy a commit to a Personal Account owned by @epleaner on Vercel.

@epleaner first needs to authorize it.

@mykeels mykeels closed this Aug 10, 2021
@vercel
Copy link

vercel bot commented Aug 10, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/epleaner/emotions-wheel/DUJALNzt3SCvUczgJSuHAGz4TxMH
✅ Preview: https://emotions-wheel-git-fork-mykeels-abstract-send-email-epleaner.vercel.app

const emailFrom = process.env.MAIL_FROM;
const url = process.env.MAIL_HOST_URL;

const ignore = async () => {
Copy link
Owner

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 (
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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';
Copy link
Owner

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';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use absolute imports

@epleaner
Copy link
Owner

Hi @mykeels , thanks for contributing! Wondering why you closed this PR before it was reviewed and merged?

@epleaner epleaner reopened this Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants