Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import { QueueEvents } from "bullmq"
import { NextFunction, Request, Response } from "express"
import pino from "pino"
import { env } from "../config"
import { getQueue } from "../queues"
import { SetCategoryForTransactionJob } from "../queues/jobs/setCategoryForTransaction"
import { addEndpointJobToQueue } from "../queues/utils"
const logger = pino()
export async function settingCategoryForTransaction(
req: Request<{ transactionId: string; category_id: string }>,
_res: Response,
next: NextFunction,
) {
logger.info("=================================== Setting category for transaction ===================================")
const queue = await getQueue()
const queueEvents = new QueueEvents(queue.name, { connection: env.redisConnection })
const { transactionId, category_id } = req.params
const job = await addEndpointJobToQueue(new SetCategoryForTransactionJob(), transactionId, { category_id })
await job.waitUntilFinished(queueEvents)
next()
}
|