Sergey Krylov ccb1082535 refactor(backend): unify envelope DTOs and fix shares/bonds inconsistency
- Replace 4 duplicate meta DTOs (AuthResponseMetaDto, PortfolioResponseMetaDto,
  BrokerResponseMetaDto, ScreenerResponseMetaDto) with shared ApiResponseMeta
- Wrap shares getShare() in ApiEnvelopePayload (was raw object, unlike bonds)
- Remove unnecessary CacheModule import from securities module
- Update portfolio controller nullDataEnvelopeSchema to use shared ApiResponseMeta
- All 116 tests pass
2026-06-25 20:20:59 +03:00

2.9 KiB
Raw Blame History

Backend Architecture Improvements — Tasks

Итерация 1: Shared envelope DTO + consistency fixes

  • 1.1 Создать документ аудита в docs/research/
  • 1.2 Вынести ApiResponseMeta в common/dto/api-response.dto.ts как единый shared класс
  • 1.3 Заменить AuthResponseMetaDto на ApiResponseMeta в auth/
  • 1.4 Заменить PortfolioResponseMetaDto на ApiResponseMeta в portfolio/
  • 1.5 Заменить BrokerResponseMetaDto на ApiResponseMeta в tbank/
  • 1.6 Поправить shares/shares.service.ts:getShare() — обернуть в ApiEnvelopePayload
  • 1.7 Убрать лишний импорт CacheModule из securities/securities.module.ts
  • 1.8 Удалить дублирующиеся envelope DTO (ScreenerResponseMetaDto, AuthResponseMetaDto, PortfolioResponseMetaDto, BrokerResponseMetaDto)
  • 1.9 npm run build успешен, 116 тестов проходят

Итерация 2: Screener caching

  • 2.1 Добавить getFullDataset() метод в ScreenerService с кешированием
  • 2.2 Использовать кеш в screen() при пустых фильтрах
  • 2.3 Тесты на кеширование screener'а

Итерация 3: Domain exceptions

  • 3.1 Создать common/exceptions/domain.exception.ts
  • 3.2 Создать common/exceptions/entity-not-found.exception.ts
  • 3.3 Создать common/exceptions/moex-api.exception.ts
  • 3.4 Создать common/exceptions/tbank-api.exception.ts
  • 3.5 Создать common/exceptions/portfolio-access.exception.ts
  • 3.6 Обновить HttpExceptionFilter для доменных исключений
  • 3.7 Заменить generic исключения в сервисах на доменные
  • 3.8 Тесты на фильтр + исключения

Итерация 4: Health check

  • 4.1 Добавить PrismaHealthIndicator в health/
  • 4.2 Добавить MoexHealthIndicator
  • 4.3 Добавить TBankHealthIndicator
  • 4.4 Обновить HealthResponseDto с checks
  • 4.5 Тесты health module

Итерация 5: RequestLoggingMiddleware DI

  • 5.1 Переписать подключение через configure() в AppModule
  • 5.2 Убрать app.use() из main.ts

Итерация 6: MoexClientService split (отдельный эпик)

  • 6.1 ADR на разделение MoexClientService
  • 6.2 spec/plan/tasks отдельного эпика
  • 6.3 Выделение rate limiter + circuit breaker в shared utils
  • 6.4 Создание MoexSecuritiesClient
  • 6.5 Создание MoexMarketDataClient
  • 6.6 Создание MoexCandlesClient
  • 6.7 Обновление всех потребителей