-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/send notification #384
Conversation
It doesn't look like the requested changes were made. @cephaschapa ? |
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.
PR feedback will be handled in a follow-up ticket/ PR.
}; | ||
const host = process.env.HOST ?? "http://localhost:3000"; | ||
|
||
const emailTemplate = ` |
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.
Create mock for the send email functionality
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.
Render template using React-Email again and move this to NotificationService.
|
||
`; | ||
|
||
if (process.env.NODE_ENV !== "test") { |
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.
Mock this so you don't need to check here
@@ -58,6 +62,19 @@ export const GET = apiHandler(async (_req: Request, context) => { | |||
|
|||
export const POST = apiHandler(async (req: NextRequest, context) => { | |||
const userId = context.session?.user.id; | |||
const service = new NotificationService(); |
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 static methods and don't create an instance of NotificationService here.
private transporter: Transporter; | ||
constructor() { | ||
this.transporter = nodemailer.createTransport({ ...smtpOptions }); | ||
} |
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.
No state in service. Create this in sendEmail or create static helper method in NotificationService.
this.transporter = nodemailer.createTransport({ ...smtpOptions }); | ||
} | ||
|
||
async 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.
Should be static so it can be called like this: await NotificationService.sendEmail(...);
Also this should handle template rendering with react-email.
Changes