♻️ 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:
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export const redisConnection = {
|
||||
host: "127.0.0.1",
|
||||
port: 6379,
|
||||
};
|
||||
+14
@@ -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);
|
||||
};
|
||||
Vendored
+6
@@ -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
@@ -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,
|
||||
});
|
||||
@@ -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);
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Queue } from "bullmq";
|
||||
import { redisConnection } from "../../connection.js";
|
||||
export const orderEmailQueue = new Queue("order-email-queue", {
|
||||
connection: redisConnection,
|
||||
});
|
||||
@@ -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,
|
||||
});
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import "./email/email.worker.js";
|
||||
import "./email/order/order.email.worker.js";
|
||||
console.log("Workers running...");
|
||||
Reference in New Issue
Block a user