Skip to content

Create Endpoint for Sending Emails #43

@aaronashby

Description

@aaronashby

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions