(Feat) BullMQ Integration for Background Jobs#124
Merged
Conversation
…for verification and password reset
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Refactoring of email sending in authentication flow:
AuthServiceto enqueue email jobs for verification and password reset instead of calling the email service directly.Error handling and logging improvements:
EmailServicemethods with try/catch blocks and added detailed logging for success and failure cases.Configuration and deployment updates:
Constants and types organization: