-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Update email sending functionality and dependencies with BullMQ
- Loading branch information
Showing
11 changed files
with
215 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"cSpell.words": ["healthz", "knexfile", "tseslint", "wajeht"] | ||
"cSpell.words": ["bullmq", "healthz", "knexfile", "tseslint", "wajeht"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Queue, Worker } from 'bullmq'; | ||
import { redis } from '../database/db'; | ||
import { sendEmail } from './utils/email'; | ||
|
||
const queueName = 'sendEmailQueue'; | ||
|
||
export const sendEmailQueue = new Queue(queueName, { | ||
connection: redis, | ||
}); | ||
|
||
const processSendEmailJob = async (job: any) => { | ||
try { | ||
job.updateProgress(0); | ||
await sendEmail({ tenant: job.data.tenant, coach: job.data.coach }); | ||
job.updateProgress(100); | ||
console.info(`Email successfully sent for tenant: ${job.data.tenant}`); | ||
} catch (error) { | ||
console.error(`Failed to send email for tenant: ${job.data.tenant}`, error); | ||
} | ||
}; | ||
|
||
new Worker(queueName, processSendEmailJob, { connection: redis }); | ||
|
||
export async function sendApproveTenantEmailJob(data: any) { | ||
try { | ||
await sendEmailQueue.add('sendEmailJob', data); | ||
} catch (error) { | ||
console.error(`Failed to add job to queue for tenant: ${data.tenant}`, error); | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
File renamed without changes.
This file contains 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
This file contains 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