import { Body , Controller , Get , Param , Post } from '@nestjs/common' ; import { CommandBus , QueryBus } from '@nestjs/cqrs' ; import { KillDragonCommand } from './commands/impl/kill-dragon.command' ; import { KillDragonDto } from './interfaces/kill-dragon-dto.interface' ; import { Hero } from './models/hero.model' ; import { GetHeroesQuery } from './queries/impl' ; @ Controller ( 'hero' ) export class HeroesGameController { constructor ( private readonly commandBus , private readonly queryBus ) { } @ Post ( ':id/kill' ) async killDragon ( @ Param ( 'id' ) id , @ Body ( ) dto ) { return this . commandBus . execute ( new KillDragonCommand ( id , dto . dragonId ) ) ; } @ Get ( ) async findAll ( ) { return this . queryBus . execute ( new GetHeroesQuery ( ) ) ; } }