Query Data from long running API?

Hi,
i have a situation here where i need to query data from an API wich takes a long time to receive. lets say hours if its really bad. so what i did is make the api kind of a two step process: first create a job, then there is a second query to get the progress or the resulting data back. i am using bullMQ for this, also to be able to directly get the queueEvents when or if a job is ready.

this example would fire whenever there is a job ready.

const queueName = 'jobque'
const queueEvents = new QueueEvents(queueName, connection)
queueEvents.on('completed', (job) => {
  console.log(`Job ${job.jobId} completed`)
})

I am now wondering where this code should live or how i would integrate such external api work in the backend in rw? Scripts? I could also add this to the db.ts wich would (for me :wink: ) feel ok to do. or directly under services?

Any hint or idea would be great! Thanks!