All files / apps/catalog/src catalog.controller.ts

92.85% Statements 13/14
75% Branches 3/4
100% Functions 2/2
91.66% Lines 11/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x     1x   1x 1x             1x 2x 2x 1x         1x           1x      
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
 
@Controller()
export class CatalogController {
  @MessagePattern('catalog.exchanges.list')
  listExchanges() {
    return [
      { id: 'bybit', name: 'Bybit' },
      { id: 'binance', name: 'Binance' },
    ];
  }
 
  @MessagePattern('catalog.symbols.list')
  listSymbols(@Payload() data: { exchangeId: string }) {
    const { exchangeId } = data;
    if (exchangeId === 'bybit') {
      return [
        { id: 'BTCUSDT', base: 'BTC', quote: 'USDT' },
        { id: 'ETHUSDT', base: 'ETH', quote: 'USDT' },
      ];
    }
    Iif (exchangeId === 'binance') {
      return [
        { id: 'BTCUSDT', base: 'BTC', quote: 'USDT' },
        { id: 'SOLUSDT', base: 'SOL', quote: 'USDT' },
      ];
    }
    return [];
  }
}