diff --git a/packages/api/src/handlers/job.ts b/packages/api/src/handlers/job.ts index d49b151d..4e0e7723 100644 --- a/packages/api/src/handlers/job.ts +++ b/packages/api/src/handlers/job.ts @@ -1,17 +1,20 @@ import { BullBoardRequest, ControllerHandlerReturnType, QueueJob } from '../../typings/app'; import { queueProvider } from '../providers/queue'; import { jobProvider } from '../providers/job'; +import { BaseAdapter } from '../queueAdapters/base'; +import { formatJob } from './queues'; async function getJobState( _req: BullBoardRequest, - job: QueueJob + job: QueueJob, + queue: BaseAdapter ): Promise { const status = await job.getState(); return { status: 200, body: { - job, + job: formatJob(job, queue), status, }, }; diff --git a/packages/api/src/handlers/queues.ts b/packages/api/src/handlers/queues.ts index 13e6fcec..bac65d1d 100644 --- a/packages/api/src/handlers/queues.ts +++ b/packages/api/src/handlers/queues.ts @@ -12,7 +12,7 @@ import { import { STATUSES } from '../constants/statuses'; import { BaseAdapter } from '../queueAdapters/base'; -const formatJob = (job: QueueJob, queue: BaseAdapter): AppJob => { +export const formatJob = (job: QueueJob, queue: BaseAdapter): AppJob => { const jobProps = job.toJSON(); const stacktrace = jobProps.stacktrace ? jobProps.stacktrace.filter(Boolean) : []; diff --git a/packages/api/src/providers/job.ts b/packages/api/src/providers/job.ts index 8cb8e951..dcdc1dca 100644 --- a/packages/api/src/providers/job.ts +++ b/packages/api/src/providers/job.ts @@ -2,7 +2,11 @@ import { BullBoardRequest, ControllerHandlerReturnType, QueueJob } from '../../t import { BaseAdapter } from '../queueAdapters/base'; export function jobProvider( - next: (req: BullBoardRequest, job: QueueJob) => Promise + next: ( + req: BullBoardRequest, + job: QueueJob, + queue: BaseAdapter + ) => Promise ) { return async ( req: BullBoardRequest, @@ -21,6 +25,6 @@ export function jobProvider( }; } - return next(req, job); + return next(req, job, queue); }; }