Skip to content

Commit

Permalink
Merge pull request #70 from ArslanKibria98/feature/node-infra
Browse files Browse the repository at this point in the history
createJob modified based on v3 flow
  • Loading branch information
zikriya authored Sep 13, 2023
2 parents e79d79e + 9d6770d commit ba198c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/controllers/job.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { jobService } from '../services';

export const createJob = async (req: Request, res: Response): Promise<any> => {
try {
const job = await jobService.addJobs(req.body);
res.send({ jobId: job.id });
const job = await jobService.createJob(req.body.transaction);
res.send({ message: 'success' });
} catch (err) {
console.error(err);
}
Expand Down
8 changes: 8 additions & 0 deletions src/services/job.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Queue, Job } from 'bullmq';
import { JobRequestBody } from '../interfaces';
import { addWorker } from './..//utils/crons/transactionsJob';
import dotenv from 'dotenv';
dotenv.config();

Expand All @@ -10,6 +11,13 @@ const queue = new Queue(process.env.QUEUE as string, {
},
});

export const createJob = async (transaction: any): Promise<any> => {
if (transaction) {
addWorker(transaction);
}
return null;
};

export const addJobs = async (jobBody: JobRequestBody): Promise<Job> => {
const job = await queue.add(jobBody.name, jobBody);
return job;
Expand Down

0 comments on commit ba198c9

Please sign in to comment.