Skip to content

(Feat) BullMQ Integration for Background Jobs#124

Merged
MuhammedMagdyy merged 19 commits into
mainfrom
feat/bullmq-integration
Sep 1, 2025
Merged

(Feat) BullMQ Integration for Background Jobs#124
MuhammedMagdyy merged 19 commits into
mainfrom
feat/bullmq-integration

Conversation

@MuhammedMagdyy

Copy link
Copy Markdown
Owner

This PR introduces background job processing for email-related tasks using BullMQ, improving scalability and reliability for sending verification and password reset emails. It adds a dedicated email worker process, refactors email sending in the authentication flow to use jobs, and enhances error handling and logging in the email service. Deployment scripts and configuration files are updated to support the new worker.

Background job integration and worker setup:

  • Added BullMQ-based job queue for email tasks.
  • Introduced a new email worker process that consumes jobs from the queue and sends emails, with robust event handling for job completion, failure, and shutdown.

Refactoring of email sending in authentication flow:

  • Updated AuthService to enqueue email jobs for verification and password reset instead of calling the email service directly.

Error handling and logging improvements:

  • Enhanced EmailService methods with try/catch blocks and added detailed logging for success and failure cases.

Configuration and deployment updates:

  • Updated PM2 ecosystem and deployment scripts to manage both the API and the new email worker process.

Constants and types organization:

  • Added queue/job-related constants and types, and adjusted magic number settings for retries and concurrency.

@MuhammedMagdyy MuhammedMagdyy self-assigned this Sep 1, 2025
Copilot AI review requested due to automatic review settings September 1, 2025 15:35
@MuhammedMagdyy MuhammedMagdyy added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 1, 2025

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces BullMQ for background job processing of email tasks, improving scalability and reliability by moving email sending operations out of the main request-response cycle.

  • Adds BullMQ-based email queue with dedicated worker process for handling verification and password reset emails
  • Refactors authentication service to enqueue email jobs instead of sending emails directly
  • Enhances error handling and logging throughout the email service with try/catch blocks

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/workers/email.worker.ts New email worker process that consumes jobs from the queue and handles email sending with event listeners
src/jobs/email.job.ts Job management class for adding verification and password reset email jobs to the queue
src/queues/email.queue.ts BullMQ queue configuration for email jobs
src/services/auth.service.ts Updated to use job queue instead of direct email service calls
src/services/email.service.ts Enhanced with try/catch blocks and detailed logging
src/services/hashing.service.ts Added HMAC hashing method for generating job IDs
src/utils/constants.ts Added queue/job constants and magic numbers for retry/concurrency settings
src/types/queue.ts Type definitions for email job data structures
package.json, ecosystem.config.js, deploy.sh Configuration updates to support the new worker process

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/workers/email.worker.ts Outdated
Comment thread src/workers/email.worker.ts
Comment thread src/services/hashing.service.ts
Comment thread src/jobs/email.job.ts
@MuhammedMagdyy MuhammedMagdyy merged commit ff524d3 into main Sep 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants