-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
src/config/config.ts
Outdated
if (process.env.NODE_ENV === 'production') return !!val; | ||
return true; |
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.
if (process.env.NODE_ENV === 'production') return !!val; | |
return true; | |
return process.env.NODE_ENV !== 'production' || val; |
src/emails/index.ts
Outdated
|
||
import { config } from 'config/config'; | ||
import { config, isProduction } from 'config/config'; | ||
|
||
const emailTransporter = nodemailer.createTransport({ |
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.
Shouldn't this also be hidden depending on the environment?
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.
By hidden do you mean something like this?
const emailTransporter = nodemailer.createTransport({ | |
const emailTransporter = isProduction | |
? nodemailer.createTransport({ | |
host: config.smtpHost, | |
port: config.smtpPort, | |
auth: { | |
user: config.smtpUser, | |
pass: config.smtpPassword, | |
}, | |
}) | |
: null; |
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.
Yes
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.
Yes
src/config/config.ts
Outdated
@@ -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; |
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.
Would you mind updating all other cases with this? Also, I think we can change this to implicit return
NOTION Ticket
Type of change
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.