- 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
2.9 KiB
2.9 KiB
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 Обновление всех потребителей