Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Workflow, StartedBy, Handles } from '@node-ts/bus-workflow'
import { SirenTestWorkflowData } from './sirent-test-workflow-data'
import { SirenTestStarted, SirenTestFailed, SirenTestPassed, EmailMaintenanceTeam, MaintenanceTeamEmailed } from '../messages'
import { inject } from 'inversify'
import { BUS_SYMBOLS, Bus } from '@node-ts/bus-core'
export class SirenTestWorkflow extends Workflow {
constructor (
@inject(BUS_SYMBOLS.Bus) private readonly bus: Bus
) {
super()
}
@StartedBy(SirenTestStarted)
handlesSirenTestStarted ({ sirenId }: SirenTestStarted): Partial {
return {
sirenId
}
}
@Handles(
SirenTestFailed,
event => event.sirenId,
'sirenId'
)
async handlesSirenTestFailed ({ sirenId }: SirenTestFailed): Promise> {
const emailMaintenanceTeam = new EmailMaintenanceTeam(
'A siren has failed its test and requires maintenance',
sirenId
)