Created
December 9, 2020 19:01
-
-
Save urbanisierung/75a3e2c3750a5e130707cfee9752cee6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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