Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { StorageController } from '../storage.controller'
import { TrelloController } from '../trello.controller'
import { ZeebeController } from '../zeebe.controller'
export class TrelloWorkerController {
constructor(
private zeebeController: ZeebeController,
private store: StorageController,
) {}
public createWorker(taskType: 'trelloAddCard') {
this.zeebeController.getZeebeClient().createWorker({
taskType,
taskHandler: async (job: any, complete: any, worker: any) => {
const idList = job.customHeaders.idlist
const name = job.customHeaders.name
const trelloController = new TrelloController(this.store)
try {
switch (taskType) {
case 'trelloAddCard':
const id: string = await trelloController.addCard(idList, name)
complete.success({ id })
break
default:
complete.failure(`Tasktype ${taskType} unknown`)
}
} catch (error) {
complete.failure('Failed to send slack message')
}
},
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment