♻️ refactor(account, order, plan, profile, support, email): restructure application modules and enhance error handling

Updated Docker configuration, refactored middleware for improved error handling, and restructured account, order, plan, profile, and support modules, including their routes, services, and validations. Enhanced email processing queues and utilities for token generation, pagination, and response management to streamline the application architecture and enhance maintainability.
This commit is contained in:
abumahid
2026-04-21 03:12:39 +06:00
parent c881efea0f
commit 0f7af70b90
94 changed files with 2593 additions and 127 deletions
+14
View File
@@ -0,0 +1,14 @@
import { otpTemplate } from "../../templates/otpTemplate.js";
import sendMail from "../../utils/mail_sender.js";
// email.processor.ts
export const emailProcessor = async (job) => {
const payload = job.data;
await sendMail({
to: payload.email,
subject: payload.subject,
htmlBody: otpTemplate(payload),
textBody: payload.textBody || "",
name: payload.name,
});
console.log("Sending email job complete:", job.id);
};
+6
View File
@@ -0,0 +1,6 @@
// email.queue.ts
import { Queue } from "bullmq";
import { redisConnection } from "../connection.js";
export const emailQueue = new Queue("email-queue", {
connection: redisConnection,
});
+7
View File
@@ -0,0 +1,7 @@
// email.worker.ts
import { Worker } from "bullmq";
import { redisConnection } from "../connection.js";
import { emailProcessor } from "./email.processor.js";
export const emailWorker = new Worker("email-queue", async (job) => emailProcessor(job), {
connection: redisConnection,
});
+12
View File
@@ -0,0 +1,12 @@
import sendMail from "../../../utils/mail_sender.js";
// email.processor.ts
export const orderEmailProcessor = async (job) => {
const payload = job.data;
await sendMail({
to: payload.email,
subject: payload.subject,
htmlBody: payload.htmlBody,
textBody: payload.textBody,
});
console.log("Sending email job complete:", job.id);
};
+5
View File
@@ -0,0 +1,5 @@
import { Queue } from "bullmq";
import { redisConnection } from "../../connection.js";
export const orderEmailQueue = new Queue("order-email-queue", {
connection: redisConnection,
});
+7
View File
@@ -0,0 +1,7 @@
// email.worker.ts
import { Worker } from "bullmq";
import { redisConnection } from "../../connection.js";
import { orderEmailProcessor } from "./order.email.processor.js";
export const emailWorker = new Worker("order-email-queue", async (job) => orderEmailProcessor(job), {
connection: redisConnection,
});