Overview
We want our donation form to send an automated "Thank You" email after a donation is successfully processed
Tasks
- Create a service for email sending
- In
apps/backend/src, create a new folder emails, make a new file emails.service.ts and create a class within it called EmailsService
- In this file, add a function
sendEmail that takes in the destination email, subject, and email content and uses an SES client to send the email
- If the send fails for any reason, log a relevant error message to the logger (
this.logger.error())
- Create a controller
- In the same folder, make a new file
emails.controller.ts and create a class within it called EmailsController
- In this file, add a POST request at the
emails/send-email endpoint that calls the sendEmail function in the service
- Create a module
- In the same folder, make a new file
emails.module.ts
- Its
controllers array should include the controller created earlier, and its providers array should include the service created earlier
- Create unit tests
emails.service.spec.ts
- Test successful email sending, and an error message being logged in case of a failure
Acceptance Criteria
- SES endpoint follows NestJS dependency injection pattern
EmailsService successfully sends emails when the endpoint is called
- Code is documented well
- Unit tests pass with mocked SES client
Overview
We want our donation form to send an automated "Thank You" email after a donation is successfully processed
Tasks
apps/backend/src, create a new folderemails, make a new fileemails.service.tsand create a class within it calledEmailsServicesendEmailthat takes in the destination email, subject, and email content and uses an SES client to send the emailthis.logger.error())emails.controller.tsand create a class within it calledEmailsControlleremails/send-emailendpoint that calls thesendEmailfunction in the serviceemails.module.tscontrollersarray should include the controller created earlier, and itsprovidersarray should include the service created earlieremails.service.spec.tsAcceptance Criteria
EmailsServicesuccessfully sends emails when the endpoint is called