inmemory to postgres

This commit is contained in:
2025-12-29 18:34:12 +01:00
parent 9e17d0752a
commit f5639a367f
176 changed files with 10175 additions and 468 deletions

View File

@@ -1,9 +1,13 @@
import { Module } from '@nestjs/common';
import { PaymentsPersistenceModule } from '../../persistence/payments/PaymentsPersistenceModule';
import { PaymentsService } from './PaymentsService';
import { PaymentsController } from './PaymentsController';
import { PaymentsProviders } from './PaymentsProviders';
@Module({
imports: [PaymentsPersistenceModule],
controllers: [PaymentsController],
providers: [PaymentsService, ...PaymentsProviders],
exports: [PaymentsService],

View File

@@ -5,7 +5,7 @@ import type { IPaymentRepository } from '@core/payments/domain/repositories/IPay
import type { IMembershipFeeRepository, IMemberPaymentRepository } from '@core/payments/domain/repositories/IMembershipFeeRepository';
import type { IPrizeRepository } from '@core/payments/domain/repositories/IPrizeRepository';
import type { IWalletRepository, ITransactionRepository } from '@core/payments/domain/repositories/IWalletRepository';
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
import type { UseCaseOutputPort } from '@core/shared/application';
// Import use cases
import { GetPaymentsUseCase } from '@core/payments/application/use-cases/GetPaymentsUseCase';
@@ -22,10 +22,6 @@ import { GetWalletUseCase } from '@core/payments/application/use-cases/GetWallet
import { ProcessWalletTransactionUseCase } from '@core/payments/application/use-cases/ProcessWalletTransactionUseCase';
// Import concrete in-memory implementations
import { InMemoryPaymentRepository } from '@adapters/payments/persistence/inmemory/InMemoryPaymentRepository';
import { InMemoryMembershipFeeRepository, InMemoryMemberPaymentRepository } from '@adapters/payments/persistence/inmemory/InMemoryMembershipFeeRepository';
import { InMemoryPrizeRepository } from '@adapters/payments/persistence/inmemory/InMemoryPrizeRepository';
import { InMemoryWalletRepository, InMemoryTransactionRepository } from '@adapters/payments/persistence/inmemory/InMemoryWalletRepository';
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
// Presenters
@@ -150,37 +146,7 @@ export const PaymentsProviders: Provider[] = [
useClass: ConsoleLogger,
},
// Repositories (repositories are injected into use cases, NOT into services)
{
provide: PAYMENT_REPOSITORY_TOKEN,
useFactory: (logger: Logger) => new InMemoryPaymentRepository(logger),
inject: [LOGGER_TOKEN],
},
{
provide: MEMBERSHIP_FEE_REPOSITORY_TOKEN,
useFactory: (logger: Logger) => new InMemoryMembershipFeeRepository(logger),
inject: [LOGGER_TOKEN],
},
{
provide: MEMBER_PAYMENT_REPOSITORY_TOKEN,
useFactory: (logger: Logger) => new InMemoryMemberPaymentRepository(logger),
inject: [LOGGER_TOKEN],
},
{
provide: PRIZE_REPOSITORY_TOKEN,
useFactory: (logger: Logger) => new InMemoryPrizeRepository(logger),
inject: [LOGGER_TOKEN],
},
{
provide: WALLET_REPOSITORY_TOKEN,
useFactory: (logger: Logger) => new InMemoryWalletRepository(logger),
inject: [LOGGER_TOKEN],
},
{
provide: TRANSACTION_REPOSITORY_TOKEN,
useFactory: (logger: Logger) => new InMemoryTransactionRepository(logger),
inject: [LOGGER_TOKEN],
},
// Repositories are provided by PaymentsPersistenceModule behind tokens.
// Use cases (use cases receive repositories, services receive use cases)
{

View File

@@ -1,9 +1,19 @@
export const PAYMENT_REPOSITORY_TOKEN = 'IPaymentRepository';
export const MEMBERSHIP_FEE_REPOSITORY_TOKEN = 'IMembershipFeeRepository';
export const MEMBER_PAYMENT_REPOSITORY_TOKEN = 'IMemberPaymentRepository';
export const PRIZE_REPOSITORY_TOKEN = 'IPrizeRepository';
export const WALLET_REPOSITORY_TOKEN = 'IWalletRepository';
export const TRANSACTION_REPOSITORY_TOKEN = 'ITransactionRepository';
import {
PAYMENTS_MEMBER_PAYMENT_REPOSITORY_TOKEN,
PAYMENTS_MEMBERSHIP_FEE_REPOSITORY_TOKEN,
PAYMENTS_PAYMENT_REPOSITORY_TOKEN,
PAYMENTS_PRIZE_REPOSITORY_TOKEN,
PAYMENTS_TRANSACTION_REPOSITORY_TOKEN,
PAYMENTS_WALLET_REPOSITORY_TOKEN,
} from '../../persistence/payments/PaymentsPersistenceTokens';
export const PAYMENT_REPOSITORY_TOKEN = PAYMENTS_PAYMENT_REPOSITORY_TOKEN;
export const MEMBERSHIP_FEE_REPOSITORY_TOKEN = PAYMENTS_MEMBERSHIP_FEE_REPOSITORY_TOKEN;
export const MEMBER_PAYMENT_REPOSITORY_TOKEN = PAYMENTS_MEMBER_PAYMENT_REPOSITORY_TOKEN;
export const PRIZE_REPOSITORY_TOKEN = PAYMENTS_PRIZE_REPOSITORY_TOKEN;
export const WALLET_REPOSITORY_TOKEN = PAYMENTS_WALLET_REPOSITORY_TOKEN;
export const TRANSACTION_REPOSITORY_TOKEN = PAYMENTS_TRANSACTION_REPOSITORY_TOKEN;
export const LOGGER_TOKEN = 'Logger';
export const GET_PAYMENTS_USE_CASE_TOKEN = 'GetPaymentsUseCase';