Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sirenId
)
await this.bus.send(emailMaintenanceTeam)
return {}
}
@Handles(
SirenTestPassed,
event => event.sirenId,
'sirenId'
)
async handlesSirenTestPassed (_: SirenTestPassed): Promise> {
return this.complete()
}
@Handles(
MaintenanceTeamEmailed,
event => event.sirenId,
'sirenId'
)
async handlesMaintenanceTeamEmailed (_: MaintenanceTeamEmailed): Promise> {
return this.complete({
maintenanceEmailSent: true
})
}
}
@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
)
await this.bus.send(emailMaintenanceTeam)
return {}
}
@Handles(
SirenTestPassed,
event => event.sirenId,
'sirenId'
)
async handlesSirenTestPassed (_: SirenTestPassed): Promise> {
return this.complete()
}
@Handles(
MaintenanceTeamEmailed,
event => event.sirenId,
'sirenId'
)
async handlesMaintenanceTeamEmailed (_: MaintenanceTeamEmailed): Promise> {
return this.complete({
maintenanceEmailSent: true
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
)
await this.bus.send(emailMaintenanceTeam)
return {}
}
@Handles(
SirenTestPassed,
event => event.sirenId,