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

chore: Avoid using SMTP sever on development #51

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gabrielmachin
Copy link
Collaborator

NOTION Ticket

Type of change

  • Fix
  • Story
  • Chore

Description of the change

Used preview-email package to avoid using a SMTP service on development and testing, also update config schema to not need to configure SMTP environment vars on development and testing.

Comment on lines 29 to 30
if (process.env.NODE_ENV === 'production') return !!val;
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (process.env.NODE_ENV === 'production') return !!val;
return true;
return process.env.NODE_ENV !== 'production' || val;


import { config } from 'config/config';
import { config, isProduction } from 'config/config';

const emailTransporter = nodemailer.createTransport({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this also be hidden depending on the environment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By hidden do you mean something like this?

Suggested change
const emailTransporter = nodemailer.createTransport({
const emailTransporter = isProduction
? nodemailer.createTransport({
host: config.smtpHost,
port: config.smtpPort,
auth: {
user: config.smtpUser,
pass: config.smtpPassword,
},
})
: null;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

@@ -41,8 +41,7 @@ const envVarsSchema = z
.string()
.transform((val) => Number(val))
.refine((val) => {
if (process.env.NODE_ENV === 'production') return !Number.isNaN(val);
return true;
return process.env.NODE_ENV !== 'production' || val;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind updating all other cases with this? Also, I think we can change this to implicit return

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