60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { DomainEventsModule } from '@lilith/domain-events';
|
|
|
|
import { HealthModule } from './modules/health/health.module';
|
|
import { SearchModule } from './modules/search/search.module';
|
|
import { AnalysisModule } from './modules/analysis/analysis.module';
|
|
import { IndexingModule } from './modules/indexing/indexing.module';
|
|
import { AssetsModule } from './modules/assets/assets.module';
|
|
import { StatsModule } from './modules/stats/stats.module';
|
|
|
|
@Module({
|
|
imports: [
|
|
// Configuration
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
envFilePath: ['.env.local', '.env'],
|
|
}),
|
|
|
|
// Domain events (infrastructure Redis for shared queue)
|
|
DomainEventsModule.forRoot({
|
|
redis: {
|
|
host: process.env.REDIS_HOST ?? 'localhost',
|
|
port: parseInt(process.env.DOMAIN_EVENTS_REDIS_PORT ?? '26379', 10),
|
|
password: process.env.REDIS_PASSWORD,
|
|
},
|
|
}),
|
|
|
|
// Database (Service-Registry + AutoLoad)
|
|
TypeOrmModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: async (config: ConfigService) => {
|
|
const { getDatabaseConfig } = await import('@lilith/service-registry');
|
|
|
|
const dbConfig = getDatabaseConfig('content-engine', {
|
|
username: config.get('DATABASE_POSTGRES_USER'),
|
|
password: config.get('DATABASE_POSTGRES_PASSWORD'),
|
|
database: config.get('DATABASE_POSTGRES_NAME'),
|
|
});
|
|
|
|
return {
|
|
...dbConfig,
|
|
autoLoadEntities: true,
|
|
synchronize: false,
|
|
logging: config.get('NODE_ENV') !== 'production',
|
|
};
|
|
},
|
|
}),
|
|
|
|
// Feature modules
|
|
HealthModule,
|
|
SearchModule,
|
|
AnalysisModule,
|
|
IndexingModule,
|
|
AssetsModule,
|
|
StatsModule,
|
|
],
|
|
})
|
|
export class AppModule {}
|