Skip to content

Instantly share code, notes, and snippets.

@urbanisierung
Created December 9, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urbanisierung/75a3e2c3750a5e130707cfee9752cee6 to your computer and use it in GitHub Desktop.
Save urbanisierung/75a3e2c3750a5e130707cfee9752cee6 to your computer and use it in GitHub Desktop.
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