78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
import { DomainEventsModule } from '@lilith/domain-events';
|
|
import { buildDeploymentRegistry } from '@lilith/service-registry';
|
|
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { ScheduleModule } from '@nestjs/schedule';
|
|
import { ThrottlerModule } from '@nestjs/throttler';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
|
import { AnalyticsModule } from './analytics/analytics.module';
|
|
import { ClipsModule } from './clips/clips.module';
|
|
import { GatewayModule } from './gateway/gateway.module';
|
|
import { HealthController } from './health.controller';
|
|
import { IntegrationModule } from './integration/integration.module';
|
|
import { MessagesModule } from './messages/messages.module';
|
|
import { TagsModule } from './tags/tags.module';
|
|
import { ThreadsModule } from './threads/threads.module';
|
|
|
|
// Build deployment registry - paths resolved via LILITH_PROJECT_ROOT env var
|
|
// Start services via ./run dev to ensure env var is set
|
|
const registry = buildDeploymentRegistry({
|
|
deploymentsPath: 'deployments/@domains',
|
|
sharedServicesPath: 'deployments/shared-services',
|
|
});
|
|
|
|
@Module({
|
|
imports: [
|
|
// Configuration
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
envFilePath: ['.env.local', '.env'],
|
|
}),
|
|
|
|
// Rate limiting
|
|
ThrottlerModule.forRoot([
|
|
{
|
|
ttl: 60000,
|
|
limit: 100,
|
|
},
|
|
]),
|
|
|
|
// Database - uses messaging shared service's PostgreSQL
|
|
TypeOrmModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: async (config: ConfigService) => {
|
|
const dbService = registry.services.get('messaging.postgresql');
|
|
|
|
return {
|
|
type: 'postgres',
|
|
host: dbService?.host || 'localhost',
|
|
port: dbService?.port || 25432,
|
|
username: config.get('DATABASE_POSTGRES_USER', 'lilith'),
|
|
password: config.get('DATABASE_POSTGRES_PASSWORD', 'lilith'),
|
|
database: config.get('DATABASE_POSTGRES_NAME', 'lilith_messaging'),
|
|
autoLoadEntities: true,
|
|
synchronize: config.get('NODE_ENV') !== 'production',
|
|
logging: config.get('NODE_ENV') !== 'production',
|
|
};
|
|
},
|
|
}),
|
|
|
|
// Scheduled jobs
|
|
ScheduleModule.forRoot(),
|
|
|
|
// Domain events
|
|
DomainEventsModule.forFeature(),
|
|
|
|
// Feature modules
|
|
AnalyticsModule,
|
|
ThreadsModule,
|
|
MessagesModule,
|
|
TagsModule,
|
|
ClipsModule,
|
|
GatewayModule,
|
|
IntegrationModule,
|
|
],
|
|
controllers: [HealthController],
|
|
})
|
|
export class AppModule {}
|