Skip to content

Instantly share code, notes, and snippets.

@patybastos
Last active March 26, 2025 13:30
Show Gist options
  • Save patybastos/0301768dd2593603b39bc5d58430ee47 to your computer and use it in GitHub Desktop.
Save patybastos/0301768dd2593603b39bc5d58430ee47 to your computer and use it in GitHub Desktop.

Applying the use of Jobs and NodeMailer(Backend)

πŸ“Œ Context

Considering the application worked on last week design-patterns-backend. Let's add some processing and routines to the system.

πŸ”₯ Tasks

1 - Process the status of all tasks.

Create scheduling jobs in BullMQ for two situations:

  • Add a status attribute that will be an enum in the Task object.

  • We should have a scheduling job to search for all open tasks that have not yet been completed and the Due Date is in past. The job should update the task status to Late. The job should be scheduled for every day at midnight.

  • We should have a scheduling job to poll all the tasks that have been completed. The job should update the task status to Done. The job should also be scheduled to run every day at midnight.

Note: Two different jobs must be created, as they have different responsibilities.

2 - Add Mailer to notify users about tasks.

Add a Mailer that should notify all active users about open and completed tasks in order of priority

  • The email must contain the title, description and priority of the tasks and these must be in order of priority.

Note:

  • The Mailer must be activated in the jobs created in task 1.
  • You should add a new attribute to the user, that is the email.

3 - Create an automatic job.

The Job must be triggered when a task is completed, sending an email to the Owner and Collaborators saying that the task has been completed.

  • The email must contain the title, description and completedAt of the Task.

🎯 Requirements

  • Add tests for the mailer and the job
  • Follow the previous studies while maintaining the code abstraction
  • Make separate commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment