message: chore(issuer-api): Emit CertificatePersistedEvent when a certificate is created directly
diff: -import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
  +import { CommandHandler, EventBus, ICommandHandler } from '@nestjs/cqrs';
  import { InjectRepository } from '@nestjs/typeorm';
  import { Repository } from 'typeorm';
  import {
  @@ -11,13 +11,15 @@ import { Certificate } from '../certificate.entity';
  import { BlockchainPropertiesService } from '../../blockchain/blockchain-properties.service';
  import { CertificateDTO } from '../certificate.dto';
  import { certificateToDto } from '../utils';
  +import { CertificatePersistedEvent } from '../events/certificate-persisted.event';
  @CommandHandler(IssueCertificateCommand)
  export class IssueCertificateHandler implements ICommandHandler<IssueCertificateCommand> {
  constructor(
  @InjectRepository(Certificate)
  private readonly repository: Repository<Certificate>,
  - private readonly blockchainPropertiesService: BlockchainPropertiesService
  + private readonly blockchainPropertiesService: BlockchainPropertiesService,
  + private readonly eventBus: EventBus
  ) {}
  async execute({
  @@ -68,6 +70,8 @@ export class IssueCertificateHandler implements ICommandHandler<IssueCertificate
  });
  const savedCertificate = await this.repository.save(certificate);
  + this.eventBus.publish(new CertificatePersistedEvent(certificate.id));
  +
  return certificateToDto(savedCertificate, userId);
  }
  }
  