56 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Backend Architecture Improvements — Tasks
## Итерация 1: Shared envelope DTO + consistency fixes ✅
- [x] 1.1 Создать документ аудита в `docs/research/`
- [x] 1.2 Вынести `ApiResponseMeta` в `common/dto/api-response.dto.ts` как единый shared класс
- [x] 1.3 Заменить `AuthResponseMetaDto` на `ApiResponseMeta` в `auth/`
- [x] 1.4 Заменить `PortfolioResponseMetaDto` на `ApiResponseMeta` в `portfolio/`
- [x] 1.5 Заменить `BrokerResponseMetaDto` на `ApiResponseMeta` в `tbank/`
- [x] 1.6 Поправить `shares/shares.service.ts:getShare()` — обернуть в `ApiEnvelopePayload`
- [x] 1.7 Убрать лишний импорт `CacheModule` из `securities/securities.module.ts`
- [x] 1.8 Удалить дублирующиеся envelope DTO (`ScreenerResponseMetaDto`, `AuthResponseMetaDto`, `PortfolioResponseMetaDto`, `BrokerResponseMetaDto`)
- [x] 1.9 `npm run build` успешен, 116 тестов проходят
## Итерация 2: Screener caching ✅
- [x] 2.1 Добавить `screenerTtl` в конфиг (900s default)
- [x] 2.2 Перевести screener на отдельный TTL
- [x] 2.3 Тест на cache key + ttl config key
## Итерация 3: Domain exceptions ✅
- [x] 3.1 Создать `common/exceptions/domain.exception.ts`
- [x] 3.2 Создать `common/exceptions/entity-not-found.exception.ts`
- [x] 3.3 Создать `common/exceptions/moex-api.exception.ts`
- [x] 3.4 Создать `common/exceptions/tbank-api.exception.ts` (+ `TBankNotConfiguredException`)
- [x] 3.5 Создать `common/exceptions/portfolio-access.exception.ts`
- [x] 3.6 Обновить `HttpExceptionFilter` с логгированием необработанных ошибок
- [x] 3.7 Заменить generic исключения в shares, bonds, portfolio, tbank сервисах
- [x] 3.8 Обновлены все тесты (117 проходят)
## Итерация 4: Health check ✅
- [x] 4.1 Создан `HealthService` с `checkPrisma()` — реальный SQL-запрос
- [x] 4.2 Добавлен `checkMoex()` — HTTP-запрос к ISS MOEX с 5s timeout
- [x] 4.3 Добавлен `checkTBank()` — проверка наличия токена
- [x] 4.4 `HealthResponseDto` обновлён: добавлено поле `checks: HealthCheckResultDto[]`
- [x] 4.5 Модуль обновлён (imports PrismaModule, providers HealthService)
- [x] 4.6 Тесты: `health.service.spec.ts` (3 теста) + `envelope-contract.spec.ts` проверяет checks
- [x] Все 120 тестов проходят
## Итерация 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 Обновление всех потребителей