Skip to content

feat: implement bullMQ#729

Open
SvenMokveldje wants to merge 5 commits intodevelopfrom
feature/implement-bullMQ
Open

feat: implement bullMQ#729
SvenMokveldje wants to merge 5 commits intodevelopfrom
feature/implement-bullMQ

Conversation

@SvenMokveldje
Copy link
Contributor

@SvenMokveldje SvenMokveldje commented Feb 2, 2026

This adds bullMQ to the SudoSOS repository and immediatly implements it for the mail services.

Description

Add 2 new environment variables:
REDIS_HOST
REDIS_PORT

Related issues/external references

Types of changes

  • New feature (non-breaking change which adds functionality)

✅ PR Checklist

  • Test Coverage: New functionality has appropriate test coverage and all tests pass (npm run test)
  • Documentation: New functionality is documented with TypeDoc comments and API documentation is updated
  • Database Changes: Database migrations created (if applicable) and tested with both SQLite and MariaDB

🔗 Additional Notes

This adds bullMQ to the SudoSOS repository and immediatly implements it
for the mail services.
@SvenMokveldje SvenMokveldje force-pushed the feature/implement-bullMQ branch from 7c6eb52 to 6309eeb Compare February 2, 2026 15:34
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

SudoSOS Coverage Report

Commit: e2d50c1
Base: develop@b568e6a

Type Base This PR
Total Statements Coverage  90.77%  90.76% (-0.01%)
Total Branches Coverage  82.97%  82.97% (+0%)
Total Functions Coverage  92.42%  92.33% (-0.09%)
Total Lines Coverage  90.97%  90.96% (-0.01%)
Details (changed files)
FileStatementsBranchesFunctionsLines
src/index.ts 90.32% 20% 62.5% 91.39%
src/mailer/mailer.ts 100% 100% 100% 100%
src/workers/mail-worker.ts 76.92% 100% 33.33% 75%
Details (all files)
FileStatementsBranchesFunctionsLines
src/index.ts 90.32% 20% 62.5% 91.39%
src/authentication/json-web-token.ts 100% 100% 100% 100%
src/authentication/token-handler.ts 100% 100% 100% 100%
src/controller/authentication-controller.ts 85.71% 95.83% 100% 85.55%
src/controller/authentication-qr-controller.ts 100% 100% 100% 100%
src/controller/authentication-secure-controller.ts 89.55% 93.93% 100% 89.55%
src/controller/balance-controller.ts 77.55% 50% 100% 77.55%
src/controller/banner-controller.ts 84.34% 95.83% 100% 84.34%
src/controller/base-controller.ts 100% 100% 100% 100%
src/controller/container-controller.ts 85.96% 78.57% 100% 85.45%
src/controller/debtor-controller.ts 83.22% 56.25% 100% 86.61%
src/controller/event-controller.ts 82.66% 90% 100% 82.66%
src/controller/event-shift-controller.ts 75.82% 90% 100% 75.82%
src/controller/inactive-administrative-cost-controller.ts 86% 72.72% 100% 86.98%
src/controller/invoice-controller.ts 78.33% 75.86% 92.3% 78.08%
src/controller/payout-request-controller.ts 69.02% 73.68% 84.61% 69.02%
src/controller/point-of-sale-controller.ts 83.79% 80.95% 100% 83.81%
src/controller/product-category-controller.ts 82.45% 100% 100% 82.45%
src/controller/product-controller.ts 85.6% 85.71% 100% 86.77%
src/controller/rbac-controller.ts 87.34% 88.23% 100% 87.09%
src/controller/root-controller.ts 86.2% 100% 100% 86.2%
src/controller/seller-payout-controller.ts 88.97% 92.3% 100% 88.88%
src/controller/server-settings-controller.ts 100% 100% 100% 100%
src/controller/simple-file-controller.ts 11.62% 0% 0% 11.62%
src/controller/stripe-controller.ts 92.59% 100% 100% 92.59%
src/controller/stripe-webhook-controller.ts 97.56% 100% 87.5% 97.56%
src/controller/sync-controller.ts 91.89% 100% 80% 94.28%
src/controller/test-controller.ts 33.33% 100% 0% 33.33%
src/controller/transaction-controller.ts 88.81% 95.45% 100% 88.6%
src/controller/transaction-summary-controller.ts 91.3% 100% 100% 90.9%
src/controller/transfer-controller.ts 91.11% 95.23% 100% 90.9%
src/controller/user-controller.ts 85.17% 91.56% 100% 85.08%
src/controller/user-notification-preference-controller.ts 85.29% 80% 100% 84.84%
src/controller/vat-group-controller.ts 87.8% 100% 100% 87.8%
src/controller/voucher-group-controller.ts 79.41% 71.42% 100% 79.41%
src/controller/write-off-controller.ts 87.83% 100% 100% 87.83%
src/controller/request/file-request.ts 0% 0% 0% 0%
src/controller/request/validators/container-request-spec.ts 100% 100% 100% 100%
src/controller/request/validators/general-validators.ts 86.53% 66.66% 77.77% 84.61%
src/controller/request/validators/inactive-administrative-cost-request-spec.ts 87.5% 66.66% 100% 100%
src/controller/request/validators/invoice-request-spec.ts 96.15% 80% 100% 100%
src/controller/request/validators/point-of-sale-request-spec.ts 95% 100% 100% 94.11%
src/controller/request/validators/product-request-spec.ts 90.32% 57.14% 100% 90%
src/controller/request/validators/rbac-request-spec.ts 100% 100% 100% 100%
src/controller/request/validators/string-spec.ts 100% 100% 100% 100%
src/controller/request/validators/update-local-request-spec.ts 100% 100% 100% 100%
src/controller/request/validators/update-nfc-request-spec.ts 100% 100% 100% 100%
src/controller/request/validators/update-pin-request-spec.ts 100% 100% 100% 100%
src/controller/request/validators/user-request-spec.ts 82.6% 25% 85.71% 83.33%
src/controller/request/validators/validation-errors.ts 87.8% 100% 62.96% 100%
src/controller/response/dinero.ts 0% 0% 0% 0%
src/database/database.ts 95.6% 33.33% 33.33% 97.75%
src/database/migrate.ts 88% 50% 50% 95.65%
src/database/seed.ts 52.5% 0% 50% 51.35%
src/database/with-manager.ts 100% 100% 100% 100%
src/entity/banner.ts 92.85% 100% 50% 91.66%
src/entity/base-entity-without-id.ts 100% 100% 100% 100%
src/entity/base-entity.ts 100% 100% 100% 100%
src/entity/server-setting.ts 84.61% 0% 100% 100%
src/entity/user-setting.ts 100% 100% 100% 100%
src/entity/vat-group.ts 100% 100% 100% 100%
src/entity/wrapped.ts 100% 100% 100% 100%
src/entity/authenticator/authentication-method.ts 100% 100% 100% 100%
src/entity/authenticator/ean-authenticator.ts 100% 100% 100% 100%
src/entity/authenticator/hash-based-authentication-method.ts 100% 100% 100% 100%
src/entity/authenticator/key-authenticator.ts 100% 100% 100% 100%
src/entity/authenticator/ldap-authenticator.ts 100% 100% 100% 100%
src/entity/authenticator/local-authenticator.ts 100% 100% 100% 100%
src/entity/authenticator/nfc-authenticator.ts 100% 100% 100% 100%
src/entity/authenticator/pin-authenticator.ts 100% 100% 100% 100%
src/entity/authenticator/qr-authenticator.ts 100% 88.88% 100% 100%
src/entity/authenticator/reset-token.ts 85.71% 100% 0% 80%
src/entity/container/container-revision.ts 95.23% 100% 83.33% 94.11%
src/entity/container/container.ts 100% 100% 100% 100%
src/entity/event/event-shift-answer.ts 100% 100% 100% 100%
src/entity/event/event-shift.ts 100% 100% 100% 100%
src/entity/event/event.ts 100% 100% 100% 100%
src/entity/file/banner-image.ts 100% 100% 100% 100%
src/entity/file/base-file.ts 100% 100% 100% 100%
src/entity/file/invoice-pdf.ts 100% 100% 100% 100%
src/entity/file/payout-request-pdf.ts 100% 100% 100% 100%
src/entity/file/pdf-able.ts 84.21% 83.33% 80% 88.23%
src/entity/file/pdf-file.ts 100% 100% 100% 100%
src/entity/file/product-image.ts 100% 100% 100% 100%
src/entity/file/seller-payout-pdf.ts 100% 100% 100% 100%
src/entity/file/write-off-pdf.ts 100% 100% 100% 100%
src/entity/fine/fine.ts 100% 100% 100% 100%
src/entity/fine/fineHandoutEvent.ts 100% 100% 100% 100%
src/entity/fine/userFineGroup.ts 100% 100% 100% 100%
src/entity/invoices/invoice-status.ts 100% 100% 100% 100%
src/entity/invoices/invoice.ts 97.72% 100% 91.66% 97.56%
src/entity/notifications/notification-log.ts 100% 100% 100% 100%
src/entity/notifications/user-notification-preference.ts 100% 100% 100% 100%
src/entity/organ/organ-membership.ts 100% 100% 100% 100%
src/entity/point-of-sale/point-of-sale-revision.ts 94.44% 100% 75% 93.33%
src/entity/point-of-sale/point-of-sale.ts 100% 100% 100% 100%
src/entity/point-of-sale/product-ordering.ts 100% 100% 100% 100%
src/entity/product/product-category.ts 100% 100% 100% 100%
src/entity/product/product-revision.ts 96.55% 100% 83.33% 96.15%
src/entity/product/product.ts 100% 100% 100% 100%
src/entity/rbac/assigned-role.ts 100% 100% 100% 100%
src/entity/rbac/permission.ts 100% 100% 100% 100%
src/entity/rbac/role-user-type.ts 100% 100% 100% 100%
src/entity/rbac/role.ts 100% 100% 100% 100%
src/entity/report/fine-report.ts 100% 100% 100% 100%
src/entity/report/inactive-administrative-cost-report.ts 100% 100% 100% 100%
src/entity/report/report.ts 100% 100% 100% 100%
src/entity/stripe/stripe-deposit.ts 100% 100% 100% 100%
src/entity/stripe/stripe-payment-intent-status.ts 100% 100% 100% 100%
src/entity/stripe/stripe-payment-intent.ts 100% 100% 100% 100%
src/entity/transactions/balance.ts 100% 100% 100% 100%
src/entity/transactions/inactive-administrative-cost.ts 100% 100% 100% 100%
src/entity/transactions/sub-transaction-row.ts 100% 100% 100% 100%
src/entity/transactions/sub-transaction.ts 100% 100% 100% 100%
src/entity/transactions/transaction.ts 100% 100% 100% 100%
src/entity/transactions/transfer.ts 100% 100% 100% 100%
src/entity/transactions/write-off.ts 100% 100% 100% 100%
src/entity/transactions/payout/base-payout.ts 100% 100% 100% 100%
src/entity/transactions/payout/payout-request-status.ts 100% 100% 100% 100%
src/entity/transactions/payout/payout-request.ts 100% 100% 100% 100%
src/entity/transactions/payout/seller-payout.ts 100% 100% 100% 100%
src/entity/transformer/dinero-transformer.ts 100% 100% 100% 100%
src/entity/user/invoice-user.ts 100% 100% 100% 100%
src/entity/user/local-user.ts 100% 100% 100% 100%
src/entity/user/member-user.ts 100% 100% 100% 100%
src/entity/user/user-voucher-group.ts 100% 100% 100% 100%
src/entity/user/user.ts 98.27% 83.33% 100% 100%
src/entity/user/voucher-group.ts 93.75% 100% 66.66% 92.3%
src/entity/wrapped/wrapped-organ-member.ts 100% 100% 100% 100%
src/errors/index.ts 100% 100% 50% 100%
src/errors/not-implemented-error.ts 20% 0% 0% 20%
src/errors/pdf-error.ts 100% 100% 100% 100%
src/files/initialize.ts 100% 100% 100% 100%
src/files/response.ts 28.57% 100% 0% 28.57%
src/files/storage/disk-storage.ts 89.28% 66.66% 80% 89.28%
src/files/storage/file-storage.ts 100% 100% 100% 100%
src/files/storage/index.ts 100% 100% 50% 100%
src/files/storage/locations.ts 100% 100% 100% 100%
src/gewis/gewis.ts 79.16% 40% 66.66% 82.6%
src/gewis/controller/gewis-authentication-controller.ts 86.66% 75% 100% 86.66%
src/gewis/controller/gewis-authentication-secure-controller.ts 93.75% 100% 100% 93.75%
src/gewis/helpers/gewis-helper.ts 100% 83.33% 100% 100%
src/gewis/service/gewisdb-sync-service.ts 91.25% 89.65% 83.33% 94.44%
src/helpers/ad.ts 90% 100% 100% 90%
src/helpers/database.ts 100% 100% 100% 100%
src/helpers/express-pdf.ts 100% 50% 100% 100%
src/helpers/hash.ts 100% 100% 100% 100%
src/helpers/logging.ts 100% 100% 100% 100%
src/helpers/ordering.ts 90.9% 75% 100% 90%
src/helpers/pagination.ts 100% 87.87% 100% 100%
src/helpers/params.ts 90% 0% 100% 90%
src/helpers/pdf.ts 94.28% 72.72% 100% 96.87%
src/helpers/pos-token-verifier.ts 100% 100% 100% 100%
src/helpers/query-filter.ts 95.08% 93.75% 94.44% 96.07%
src/helpers/raw-body.ts 100% 100% 100% 100%
src/helpers/revision-to-response.ts 87.5% 50% 77.77% 90.9%
src/helpers/specification-validation.ts 94.59% 87.5% 88.88% 96.87%
src/helpers/timestamps.ts 58.82% 60% 66.66% 56.25%
src/helpers/token-helper.ts 100% 100% 100% 100%
src/helpers/transaction-mapper.ts 90% 100% 76.19% 91.07%
src/helpers/validators.ts 95.45% 88.88% 100% 98.83%
src/html/base.html.ts 100% 100% 100% 100%
src/html/inactive-administrative-cost-report.html.ts 40% 100% 0% 40%
src/html/transaction.html.ts 100% 100% 100% 100%
src/html/transfer.html.ts 100% 100% 100% 100%
src/mailer/index.ts 100% 100% 100% 100%
src/mailer/mail-body-generator.ts 91.66% 83.33% 100% 91.66%
src/mailer/mail-message.ts 100% 100% 100% 100%
src/mailer/mailer.ts 100% 100% 100% 100%
src/mailer/transporter.ts 100% 100% 100% 100%
src/mailer/messages/changed-pin.ts 85.71% 100% 0% 85.71%
src/mailer/messages/forgot-event-planning.ts 46.15% 100% 0% 46.15%
src/mailer/messages/hello-world.ts 100% 100% 100% 100%
src/mailer/messages/inactive-administrative-cost-notification.ts 76.92% 100% 57.14% 76.92%
src/mailer/messages/index.ts 100% 100% 100% 100%
src/mailer/messages/mail-content-builder.ts 81.81% 53.33% 100% 81.81%
src/mailer/messages/membership-expiry-notification.ts 88.23% 50% 71.42% 88.23%
src/mailer/messages/password-reset.ts 33.33% 0% 0% 33.33%
src/mailer/messages/transaction-notification.ts 87.8% 30.76% 69.23% 87.17%
src/mailer/messages/user-debt-notification.ts 85.71% 100% 60% 85.71%
src/mailer/messages/user-got-fined.ts 76.92% 100% 57.14% 76.92%
src/mailer/messages/user-got-inactive-administrative-cost.ts 80% 100% 62.5% 80%
src/mailer/messages/user-type-updated-with-reset.ts 62.5% 100% 20% 62.5%
src/mailer/messages/user-type-updated.ts 83.33% 100% 60% 83.33%
src/mailer/messages/user-will-get-fined.ts 33.33% 0% 0% 33.33%
src/mailer/messages/welcome-to-sudosos.ts 85.71% 100% 60% 85.71%
src/mailer/messages/welcome-with-reset.ts 85.71% 100% 60% 85.71%
src/middleware/policy-middleware.ts 100% 100% 100% 100%
src/middleware/request-validator-middleware.ts 92.3% 66.66% 100% 100%
src/middleware/restriction-middleware.ts 96.15% 93.33% 75% 100%
src/middleware/token-middleware.ts 100% 100% 100% 100%
src/notifications/index.ts 100% 100% 80% 100%
src/notifications/notification-options.ts 96.36% 100% 92.3% 96.36%
src/notifications/notification-registry.ts 100% 100% 100% 100%
src/notifications/notification-types.ts 92.85% 75% 75% 92.85%
src/notifications/notifier.ts 89.36% 50% 100% 88.88%
src/notifications/channels/abstract-channel.ts 80% 100% 66.66% 80%
src/notifications/channels/mail-channel.ts 100% 100% 100% 100%
src/notifications/templates/notification-email-templates.ts 88.88% 100% 66.66% 88.88%
src/rbac/default-roles.ts 100% 100% 100% 100%
src/rbac/role-manager.ts 84.61% 81.81% 91.66% 86.66%
src/server-settings/server-settings-store.ts 98.24% 88.88% 100% 100%
src/server-settings/setting-defaults.ts 100% 100% 100% 100%
src/service/ad-service.ts 96.61% 66.66% 100% 96.07%
src/service/authentication-service.ts 93.22% 77.5% 100% 92.72%
src/service/balance-service.ts 98.57% 87.5% 100% 98.4%
src/service/banner-service.ts 96.15% 91.3% 100% 96.07%
src/service/container-service.ts 97.14% 86.2% 100% 100%
src/service/debtor-service.ts 98.46% 86.95% 100% 100%
src/service/event-service.ts 100% 100% 100% 100%
src/service/file-service.ts 97.22% 72.22% 100% 97.18%
src/service/inactive-administrative-cost-service.ts 95% 65.21% 100% 95.65%
src/service/invoice-service.ts 94.54% 63.15% 95.65% 97.97%
src/service/payout-request-service.ts 100% 97.36% 100% 100%
src/service/point-of-sale-service.ts 97.33% 89.47% 100% 100%
src/service/product-category-service.ts 100% 100% 100% 100%
src/service/product-service.ts 94.84% 80.76% 96% 95.18%
src/service/qr-service.ts 78.94% 0% 100% 78.94%
src/service/rbac-service.ts 96.62% 87.5% 100% 100%
src/service/report-service.ts 99.03% 85.71% 100% 100%
src/service/seller-payout-service.ts 100% 100% 100% 100%
src/service/stripe-service.ts 97.1% 89.65% 100% 96.92%
src/service/transaction-service.ts 96.23% 83.63% 100% 95.95%
src/service/transaction-summary-service.ts 93.54% 100% 87.5% 92.59%
src/service/transfer-service.ts 100% 98.21% 100% 100%
src/service/user-notification-preference-service.ts 97.01% 64.7% 100% 96.92%
src/service/user-service.ts 98.4% 83.15% 97.14% 98.81%
src/service/vat-group-service.ts 97.36% 76.47% 93.75% 96.96%
src/service/voucher-group-service.ts 100% 100% 100% 100%
src/service/websocket-service.ts 85.71% 71.42% 70% 85.71%
src/service/wrapped-service.ts 93.04% 70.78% 100% 96.53%
src/service/write-off-service.ts 100% 85.71% 100% 100%
src/service/pdf/inactive-administrative-cost-report-pdf-service.ts 80% 0% 50% 80%
src/service/pdf/invoice-pdf-service.ts 97.05% 87.5% 100% 96.66%
src/service/pdf/payout-request-pdf-service.ts 100% 100% 100% 100%
src/service/pdf/pdf-service.ts 81.25% 42.85% 82.35% 82.53%
src/service/pdf/report-pdf-service.ts 100% 100% 100% 100%
src/service/pdf/seller-payout-pdf-service.ts 100% 100% 100% 100%
src/service/pdf/transaction-pdf-service.ts 100% 100% 100% 100%
src/service/pdf/transfer-pdf-service.ts 100% 72% 100% 100%
src/service/pdf/user-report-pdf-service.ts 95% 50% 100% 100%
src/service/pdf/write-off-pdf-service.ts 100% 100% 100% 100%
src/service/sync/sync-manager.ts 100% 100% 100% 100%
src/service/sync/sync-service-factory.ts 100% 100% 100% 100%
src/service/sync/sync-service.ts 77.77% 50% 33.33% 75%
src/service/sync/user/ldap-sync-service.ts 93.54% 78.26% 100% 94.04%
src/service/sync/user/user-sync-manager.ts 100% 100% 100% 100%
src/service/sync/user/user-sync-service-factory.ts 100% 100% 100% 100%
src/service/sync/user/user-sync-service.ts 100% 100% 100% 100%
src/start/swagger.ts 80.95% 53.33% 66.66% 80.48%
src/subscriber/index.ts 100% 100% 100% 100%
src/subscriber/transaction-subscriber.ts 88.23% 88% 100% 88.88%
src/subscriber/transfer-subscriber.ts 100% 100% 100% 100%
src/user-settings/user-settings-defaults.ts 100% 100% 100% 100%
src/user-settings/user-settings-store.ts 87.5% 77.77% 100% 87.09%
src/workers/mail-worker.ts 76.92% 100% 33.33% 75%

@SvenMokveldje SvenMokveldje marked this pull request as ready for review February 2, 2026 16:11
Copilot AI review requested due to automatic review settings February 2, 2026 16:11
Copy link

Copilot AI left a comment

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 implements BullMQ, a Redis-based job queue library, to handle email sending asynchronously in the SudoSOS application. Previously, emails were sent directly through SMTP, which could cause delays and failures to impact application performance. With BullMQ, emails are now queued and processed by a dedicated worker.

Changes:

  • Added BullMQ dependency (v5.67.2) and Redis connection configuration
  • Refactored Mailer class to queue emails instead of sending directly via SMTP
  • Created a new mail worker to process queued email jobs
  • Updated all tests to stub BullMQ Queue.add() instead of nodemailer.sendMail()

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
package.json Added bullmq dependency
package-lock.json Added bullmq and its transitive dependencies (ioredis, msgpackr, etc.)
.env.example Added REDIS_HOST and REDIS_PORT environment variables
src/mailer/mailer.ts Replaced direct SMTP sending with queue-based approach using BullMQ
src/workers/mail-worker.ts New worker that processes email jobs from the queue
src/index.ts Starts the mail worker on application startup
test/unit/mailer/mailer.ts Updated tests to stub Queue instead of nodemailer transport
test/unit/subscribe/transaction-subscriber.ts Updated tests to verify queue operations instead of SMTP calls
test/unit/service/inactive-administrative-cost-service.ts Updated tests with Queue stubs and cleanup improvements
test/unit/gewis/gewisdb-sync-service.ts Updated tests to verify queue operations
test/unit/controller/inactive-administrative-cost-controller.ts Updated tests to verify queue operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@RubenLWF RubenLWF left a comment

Choose a reason for hiding this comment

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

Please have a look at the copilot comments

@SvenMokveldje SvenMokveldje force-pushed the feature/implement-bullMQ branch from 917d9ad to 13caec7 Compare February 4, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants