import { Controller } from '@nestjs/common' ; import { MessagePattern , Payload } from '@nestjs/microservices' ; import { LoggerLevelNames , LoggerService } from '@fc/logger' ; import { TracksProtocol } from '@fc/microservices' ; import { ICsmrTracksOutputTrack } from '../interfaces' ; import { CsmrTracksService } from '../services' ; @ Controller ( ) export class CsmrTracksController { constructor ( private readonly logger , private readonly csmrTracks ) { this . logger . setContext ( this . constructor . name ) ; } param payload example returns { Promise < ICsmrTracksOutputTrack [ ] > } @ MessagePattern ( TracksProtocol . Commands . GET ) async getTracks ( @ Payload ( ) payload ) { let tracks ; this . logger . debug ( `New message received with pattern "${ TracksProtocol . Commands . GET }"` ) ; try { const { identity } = payload ; tracks = await this . csmrTracks . getList ( identity ) ; } catch ( error ) { this . logger . trace ( { error } , LoggerLevelNames . WARN ) ; tracks = [ ] ; } this . logger . trace ( { input : { payload } , name : 'TracksProtocol.Commands.GET' , output : { tracks } , patern : TracksProtocol . Commands . GET , } ) ; return tracks ; } }