2025-08-30 16:45:22 +09:00
|
|
|
import { Module } from '@nestjs/common';
|
|
|
|
|
import { RouterModule } from '@nestjs/core';
|
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
|
import { ThrottlerModule } from '@nestjs/throttler';
|
2025-08-21 15:24:40 +09:00
|
|
|
|
2025-08-30 16:45:22 +09:00
|
|
|
// Configuration
|
|
|
|
|
import { appConfig } from './common/config/app.config';
|
|
|
|
|
import { createThrottlerConfig } from './common/config/throttler.config';
|
|
|
|
|
import { apiRoutes } from './common/config/router.config';
|
2025-08-20 18:02:50 +09:00
|
|
|
|
2025-08-30 16:45:22 +09:00
|
|
|
// Core Infrastructure Modules
|
|
|
|
|
import { LoggingModule } from './common/logging/logging.module';
|
|
|
|
|
import { PrismaModule } from './common/prisma/prisma.module';
|
|
|
|
|
import { RedisModule } from './common/redis/redis.module';
|
|
|
|
|
import { CacheModule } from './common/cache/cache.module';
|
|
|
|
|
import { AuditModule } from './common/audit/audit.module';
|
|
|
|
|
import { EmailModule } from './common/email/email.module';
|
|
|
|
|
|
|
|
|
|
// External Integration Modules
|
|
|
|
|
import { VendorsModule } from './vendors/vendors.module';
|
|
|
|
|
import { JobsModule } from './jobs/jobs.module';
|
|
|
|
|
|
|
|
|
|
// Feature Modules
|
|
|
|
|
import { AuthModule } from './auth/auth.module';
|
|
|
|
|
import { UsersModule } from './users/users.module';
|
|
|
|
|
import { MappingsModule } from './mappings/mappings.module';
|
|
|
|
|
import { CatalogModule } from './catalog/catalog.module';
|
|
|
|
|
import { OrdersModule } from './orders/orders.module';
|
|
|
|
|
import { InvoicesModule } from './invoices/invoices.module';
|
|
|
|
|
import { SubscriptionsModule } from './subscriptions/subscriptions.module';
|
|
|
|
|
import { CasesModule } from './cases/cases.module';
|
|
|
|
|
import { WebhooksModule } from './webhooks/webhooks.module';
|
|
|
|
|
|
|
|
|
|
// System Modules
|
|
|
|
|
import { HealthModule } from './health/health.module';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Main application module
|
|
|
|
|
*
|
|
|
|
|
* Architecture:
|
|
|
|
|
* - Core infrastructure modules provide foundational services
|
|
|
|
|
* - External integration modules handle third-party services
|
|
|
|
|
* - Feature modules implement business logic
|
|
|
|
|
* - System modules provide monitoring and health checks
|
|
|
|
|
*
|
|
|
|
|
* All feature modules are grouped under "/api" prefix via RouterModule
|
|
|
|
|
* Health endpoints remain at root level for monitoring tools
|
|
|
|
|
*/
|
2025-08-20 18:02:50 +09:00
|
|
|
@Module({
|
|
|
|
|
imports: [
|
2025-08-30 16:45:22 +09:00
|
|
|
// === CONFIGURATION ===
|
|
|
|
|
ConfigModule.forRoot(appConfig),
|
2025-08-22 17:02:49 +09:00
|
|
|
|
2025-08-30 16:45:22 +09:00
|
|
|
// === INFRASTRUCTURE ===
|
2025-08-21 15:24:40 +09:00
|
|
|
LoggingModule,
|
2025-08-22 17:02:49 +09:00
|
|
|
ThrottlerModule.forRootAsync({
|
|
|
|
|
imports: [ConfigModule],
|
|
|
|
|
inject: [ConfigService],
|
2025-08-30 16:45:22 +09:00
|
|
|
useFactory: createThrottlerConfig,
|
2025-08-22 17:02:49 +09:00
|
|
|
}),
|
2025-08-20 18:02:50 +09:00
|
|
|
|
2025-08-30 16:45:22 +09:00
|
|
|
// === CORE SERVICES ===
|
2025-08-20 18:02:50 +09:00
|
|
|
PrismaModule,
|
|
|
|
|
RedisModule,
|
2025-08-21 15:24:40 +09:00
|
|
|
CacheModule,
|
2025-08-20 18:02:50 +09:00
|
|
|
AuditModule,
|
2025-08-30 16:45:22 +09:00
|
|
|
EmailModule,
|
|
|
|
|
|
|
|
|
|
// === EXTERNAL INTEGRATIONS ===
|
2025-08-20 18:02:50 +09:00
|
|
|
VendorsModule,
|
|
|
|
|
JobsModule,
|
2025-08-22 17:02:49 +09:00
|
|
|
|
2025-08-30 16:45:22 +09:00
|
|
|
// === FEATURE MODULES ===
|
2025-08-20 18:02:50 +09:00
|
|
|
AuthModule,
|
|
|
|
|
UsersModule,
|
|
|
|
|
MappingsModule,
|
|
|
|
|
CatalogModule,
|
|
|
|
|
OrdersModule,
|
|
|
|
|
InvoicesModule,
|
|
|
|
|
SubscriptionsModule,
|
|
|
|
|
CasesModule,
|
|
|
|
|
WebhooksModule,
|
2025-08-30 16:45:22 +09:00
|
|
|
|
|
|
|
|
// === SYSTEM MODULES ===
|
|
|
|
|
HealthModule,
|
|
|
|
|
|
|
|
|
|
// === ROUTING ===
|
|
|
|
|
RouterModule.register(apiRoutes),
|
2025-08-20 18:02:50 +09:00
|
|
|
],
|
|
|
|
|
})
|
2025-08-30 16:45:22 +09:00
|
|
|
export class AppModule {}
|