platform-codebase/features/webmap/backend-api/src/app.module.ts

69 lines
2.1 KiB
TypeScript
Executable file

// Root application module
import { buildDeploymentRegistry } from '@lilith/service-registry';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ThrottlerModule } from '@nestjs/throttler';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from './features/auth/auth.module';
import { ContentModule } from './features/content/content.module';
import { ThemesModule } from './features/themes/themes.module';
import { WebsitesModule } from './features/websites/websites.module';
import { HealthModule } from './health/health.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, // 1 minute
limit: 100, // 100 requests per minute
},
]),
// Database - uses webmap shared service's PostgreSQL
TypeOrmModule.forRootAsync({
inject: [ConfigService],
useFactory: async (config: ConfigService) => {
// Get database configuration from deployment registry
const dbService = registry.services.get('webmap.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_webmap',
autoLoadEntities: true,
synchronize: false,
logging: config.get('NODE_ENV') !== 'production',
};
},
}),
// Health checks
HealthModule,
// Feature modules
AuthModule,
WebsitesModule,
ContentModule,
ThemesModule,
],
})
export class AppModule {}