import { CommandHandler } from '@nestjs/cqrs'; import { CreateAdCommand } from '../../commands/create-ad.command'; import { Ad } from '../entities/ad'; import { AdRepository } from '../../adapters/secondaries/ad.repository'; @CommandHandler(CreateAdCommand) export class CreateAdUseCase { constructor(private readonly adRepository: AdRepository) {} async execute(command: CreateAdCommand): Promise { try { return await this.adRepository.createAd(command.createAdRequest); } catch (error) { throw error; } } }