feat: add portfolio

This commit is contained in:
2026-08-13 22:44:53 +03:00
parent c0a4a93880
commit dfca11c81f
11 changed files with 771 additions and 78 deletions
+4
View File
@@ -4,6 +4,7 @@ import { Environment } from '../config/env.validation';
import { PrismaService } from '../prisma/prisma.service';
import { TbankClient } from './tbank.client';
import { TbankCrypto } from './tbank.crypto';
import { PortfolioService } from './portfolio.service';
@Injectable()
export class TbankConnectionService {
@@ -13,6 +14,7 @@ export class TbankConnectionService {
private readonly prisma: PrismaService,
config: ConfigService<Environment, true>,
private readonly tbank: TbankClient,
private readonly portfolio: PortfolioService,
) {
this.crypto = TbankCrypto.fromBase64(
config.getOrThrow('TOKEN_ENCRYPTION_KEY'),
@@ -52,6 +54,7 @@ export class TbankConnectionService {
connectedAt: new Date(),
},
});
this.portfolio.invalidate(userId);
return {
connected: true,
connectedAt: connection.connectedAt.toISOString(),
@@ -60,5 +63,6 @@ export class TbankConnectionService {
async delete(userId: string): Promise<void> {
await this.prisma.tbankConnection.deleteMany({ where: { userId } });
this.portfolio.invalidate(userId);
}
}