86 lines
2.7 KiB
TypeScript
Executable file
86 lines
2.7 KiB
TypeScript
Executable file
import { DomainEventsModule } from '@lilith/domain-events'
|
|
import { BullModule } from '@nestjs/bullmq'
|
|
import { Module } from '@nestjs/common'
|
|
import { ConfigModule, ConfigService } from '@nestjs/config'
|
|
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
|
|
import { AdminModule } from './admin/admin.module'
|
|
import { EarningsModule } from './earnings/earnings.module'
|
|
import { GiftCardsModule } from './gift-cards/gift-cards.module'
|
|
import { NOWPaymentsModule } from './nowpayments/nowpayments.module'
|
|
import { PaymentMethodsModule } from './payment-methods/payment-methods.module'
|
|
import { PayoutsModule } from './payouts/payouts.module'
|
|
import { ProvidersModule } from './providers/providers.module'
|
|
import { SegpayModule } from './segpay/segpay.module'
|
|
import { getDatabaseConfig } from './src/database/database.config'
|
|
import { SubscriptionsModule } from './subscriptions/subscriptions.module'
|
|
import { TransactionsModule } from './transactions/transactions.module'
|
|
import { WebhooksModule } from './webhooks/webhooks.module'
|
|
|
|
/**
|
|
* Payments Module
|
|
*
|
|
* Main module for payment processing functionality.
|
|
* Includes:
|
|
* - Payment providers (Segpay, NOWPayments)
|
|
* - Payment provider factory for provider selection
|
|
* - Webhook handling
|
|
* - Gift card purchases
|
|
* - Domain events for funnel tracking
|
|
* - Subscription, transaction, payment method, and payout management
|
|
* - Creator earnings tracking
|
|
* - Admin dashboard and management
|
|
*/
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
envFilePath: ['.env.local', '.env'],
|
|
}),
|
|
// Database configuration
|
|
TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
useFactory: getDatabaseConfig,
|
|
inject: [ConfigService],
|
|
}),
|
|
// Queue infrastructure for domain events
|
|
BullModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
useFactory: (configService: ConfigService) => {
|
|
const password = configService.get('DATABASE_REDIS_PASSWORD')
|
|
return {
|
|
connection: {
|
|
host: configService.get('DATABASE_REDIS_HOST', 'localhost'),
|
|
port: configService.get<number>('DATABASE_REDIS_PORT', 26379),
|
|
...(password && { password }),
|
|
},
|
|
}
|
|
},
|
|
inject: [ConfigService],
|
|
}),
|
|
DomainEventsModule.forFeature(),
|
|
SegpayModule,
|
|
NOWPaymentsModule,
|
|
ProvidersModule,
|
|
WebhooksModule,
|
|
GiftCardsModule,
|
|
SubscriptionsModule,
|
|
PaymentMethodsModule,
|
|
TransactionsModule,
|
|
PayoutsModule,
|
|
EarningsModule,
|
|
AdminModule,
|
|
],
|
|
exports: [
|
|
SegpayModule,
|
|
NOWPaymentsModule,
|
|
ProvidersModule,
|
|
GiftCardsModule,
|
|
SubscriptionsModule,
|
|
PaymentMethodsModule,
|
|
TransactionsModule,
|
|
PayoutsModule,
|
|
EarningsModule,
|
|
],
|
|
})
|
|
export class PaymentsModule {}
|