import IEntity from '../domain/IEntity' ; import EventPublisher from './eventPublisher' ; export abstract class AbstractApplicationService { protected constructor ( private eventPublisher ) { } param { IEntity } entity param { string } source return protected async sendApplicationEvents ( source , entity ) { if ( process . env . SEND_DOMAIN_EVENTS === 'true' ) { await this . eventPublisher . publish ( source , entity . releaseDomainEvents ( ) ) ; } return true ; } }