125 lines
5.4 KiB
TypeScript
125 lines
5.4 KiB
TypeScript
import { Provider } from '@nestjs/common';
|
|
|
|
// Import core interfaces
|
|
import type { IMemberPaymentRepository, IMembershipFeeRepository } from '@core/payments/domain/repositories/MembershipFeeRepository';
|
|
import type { IPaymentRepository } from '@core/payments/domain/repositories/PaymentRepository';
|
|
import type { IPrizeRepository } from '@core/payments/domain/repositories/PrizeRepository';
|
|
import type { ITransactionRepository, IWalletRepository } from '@core/payments/domain/repositories/WalletRepository';
|
|
|
|
// Import use cases
|
|
import { AwardPrizeUseCase } from '@core/payments/application/use-cases/AwardPrizeUseCase';
|
|
import { CreatePaymentUseCase } from '@core/payments/application/use-cases/CreatePaymentUseCase';
|
|
import { CreatePrizeUseCase } from '@core/payments/application/use-cases/CreatePrizeUseCase';
|
|
import { DeletePrizeUseCase } from '@core/payments/application/use-cases/DeletePrizeUseCase';
|
|
import { GetMembershipFeesUseCase } from '@core/payments/application/use-cases/GetMembershipFeesUseCase';
|
|
import { GetPaymentsUseCase } from '@core/payments/application/use-cases/GetPaymentsUseCase';
|
|
import { GetPrizesUseCase } from '@core/payments/application/use-cases/GetPrizesUseCase';
|
|
import { GetWalletUseCase } from '@core/payments/application/use-cases/GetWalletUseCase';
|
|
import { ProcessWalletTransactionUseCase } from '@core/payments/application/use-cases/ProcessWalletTransactionUseCase';
|
|
import { UpdateMemberPaymentUseCase } from '@core/payments/application/use-cases/UpdateMemberPaymentUseCase';
|
|
import { UpdatePaymentStatusUseCase } from '@core/payments/application/use-cases/UpdatePaymentStatusUseCase';
|
|
import { UpsertMembershipFeeUseCase } from '@core/payments/application/use-cases/UpsertMembershipFeeUseCase';
|
|
|
|
// Import concrete in-memory implementations
|
|
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
|
|
|
|
import {
|
|
AWARD_PRIZE_USE_CASE_TOKEN,
|
|
CREATE_PAYMENT_USE_CASE_TOKEN,
|
|
CREATE_PRIZE_USE_CASE_TOKEN,
|
|
DELETE_PRIZE_USE_CASE_TOKEN,
|
|
GET_MEMBERSHIP_FEES_USE_CASE_TOKEN,
|
|
GET_PAYMENTS_USE_CASE_TOKEN,
|
|
GET_PRIZES_USE_CASE_TOKEN,
|
|
GET_WALLET_USE_CASE_TOKEN,
|
|
LOGGER_TOKEN,
|
|
MEMBERSHIP_FEE_REPOSITORY_TOKEN,
|
|
MEMBER_PAYMENT_REPOSITORY_TOKEN,
|
|
PAYMENT_REPOSITORY_TOKEN,
|
|
PRIZE_REPOSITORY_TOKEN,
|
|
PROCESS_WALLET_TRANSACTION_USE_CASE_TOKEN,
|
|
TRANSACTION_REPOSITORY_TOKEN,
|
|
UPDATE_MEMBER_PAYMENT_USE_CASE_TOKEN,
|
|
UPDATE_PAYMENT_STATUS_USE_CASE_TOKEN,
|
|
UPSERT_MEMBERSHIP_FEE_USE_CASE_TOKEN,
|
|
WALLET_REPOSITORY_TOKEN,
|
|
} from './PaymentsTokens';
|
|
|
|
export * from './PaymentsTokens';
|
|
|
|
export const PaymentsProviders: Provider[] = [
|
|
|
|
// Logger
|
|
{
|
|
provide: LOGGER_TOKEN,
|
|
useClass: ConsoleLogger,
|
|
},
|
|
|
|
// Repositories are provided by PaymentsPersistenceModule behind tokens.
|
|
|
|
// Use cases (use cases receive repositories, services receive use cases)
|
|
{
|
|
provide: GET_PAYMENTS_USE_CASE_TOKEN,
|
|
useFactory: (paymentRepo: IPaymentRepository) => new GetPaymentsUseCase(paymentRepo),
|
|
inject: [PAYMENT_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: CREATE_PAYMENT_USE_CASE_TOKEN,
|
|
useFactory: (paymentRepo: IPaymentRepository) => new CreatePaymentUseCase(paymentRepo),
|
|
inject: [PAYMENT_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: UPDATE_PAYMENT_STATUS_USE_CASE_TOKEN,
|
|
useFactory: (paymentRepo: IPaymentRepository) => new UpdatePaymentStatusUseCase(paymentRepo),
|
|
inject: [PAYMENT_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: GET_MEMBERSHIP_FEES_USE_CASE_TOKEN,
|
|
useFactory: (membershipFeeRepo: IMembershipFeeRepository, memberPaymentRepo: IMemberPaymentRepository) =>
|
|
new GetMembershipFeesUseCase(membershipFeeRepo, memberPaymentRepo),
|
|
inject: [MEMBERSHIP_FEE_REPOSITORY_TOKEN, MEMBER_PAYMENT_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: UPSERT_MEMBERSHIP_FEE_USE_CASE_TOKEN,
|
|
useFactory: (membershipFeeRepo: IMembershipFeeRepository) => new UpsertMembershipFeeUseCase(membershipFeeRepo),
|
|
inject: [MEMBERSHIP_FEE_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: UPDATE_MEMBER_PAYMENT_USE_CASE_TOKEN,
|
|
useFactory: (membershipFeeRepo: IMembershipFeeRepository, memberPaymentRepo: IMemberPaymentRepository) =>
|
|
new UpdateMemberPaymentUseCase(membershipFeeRepo, memberPaymentRepo),
|
|
inject: [MEMBERSHIP_FEE_REPOSITORY_TOKEN, MEMBER_PAYMENT_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: GET_PRIZES_USE_CASE_TOKEN,
|
|
useFactory: (prizeRepo: IPrizeRepository) => new GetPrizesUseCase(prizeRepo),
|
|
inject: [PRIZE_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: CREATE_PRIZE_USE_CASE_TOKEN,
|
|
useFactory: (prizeRepo: IPrizeRepository) => new CreatePrizeUseCase(prizeRepo),
|
|
inject: [PRIZE_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: AWARD_PRIZE_USE_CASE_TOKEN,
|
|
useFactory: (prizeRepo: IPrizeRepository) => new AwardPrizeUseCase(prizeRepo),
|
|
inject: [PRIZE_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: DELETE_PRIZE_USE_CASE_TOKEN,
|
|
useFactory: (prizeRepo: IPrizeRepository) => new DeletePrizeUseCase(prizeRepo),
|
|
inject: [PRIZE_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: GET_WALLET_USE_CASE_TOKEN,
|
|
useFactory: (walletRepo: IWalletRepository, transactionRepo: ITransactionRepository) =>
|
|
new GetWalletUseCase(walletRepo, transactionRepo),
|
|
inject: [WALLET_REPOSITORY_TOKEN, TRANSACTION_REPOSITORY_TOKEN],
|
|
},
|
|
{
|
|
provide: PROCESS_WALLET_TRANSACTION_USE_CASE_TOKEN,
|
|
useFactory: (walletRepo: IWalletRepository, transactionRepo: ITransactionRepository) =>
|
|
new ProcessWalletTransactionUseCase(walletRepo, transactionRepo),
|
|
inject: [WALLET_REPOSITORY_TOKEN, TRANSACTION_REPOSITORY_TOKEN],
|
|
},
|
|
]; |