Skip to content

Commit f9e1fc2

Browse files
Setup email jobs.
1 parent 2fe7bac commit f9e1fc2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/controllers/checkout/checkoutController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { ICartItem } from "../../models/cartItem/cartItem.interface";
2424
import Stripe from "stripe";
2525
// modules imports
2626

27+
28+
2729
// checkout with cash
2830
export const checkoutWithCash = catchAsync(
2931
async (req: CheckoutRequest, res: Response, next: NextFunction) => {

src/jobs/queueJobs/emailsQueue.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Bull from "bull";
2+
3+
export const emailQueue = new Bull("email-queue", {
4+
redis: {
5+
host: "localhost",
6+
port: 6379,
7+
},
8+
});
9+
10+
// emailQueue.process(async (job) => {
11+
// // send email logic here
12+
// console.log("Sending email to: ", job);
13+
// });
14+
15+
emailQueue.process(async (job) => {
16+
return console.log("kill all them", job);
17+
});
18+
19+
// Define a local completed event
20+
emailQueue.on("completed", (job, result) => {
21+
console.log(`Job completed with result ${result}`);
22+
});

0 commit comments

Comments
 (0)