44 lines
1.5 KiB
TypeScript
Executable file
44 lines
1.5 KiB
TypeScript
Executable file
import { buildDeploymentRegistry } from '@lilith/service-registry';
|
|
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
|
import { HealthController } from './health/health.controller';
|
|
import { FlagsModule } from './modules/flags';
|
|
|
|
// 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: [
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
envFilePath: ['.env.local', '.env'],
|
|
}),
|
|
TypeOrmModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: async (config: ConfigService) => {
|
|
const dbService = registry.services.get('feature-flags.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_feature_flags'),
|
|
autoLoadEntities: true,
|
|
synchronize: config.get('DB_SYNCHRONIZE', 'false') === 'true',
|
|
logging: config.get('DB_LOGGING', 'false') === 'true',
|
|
};
|
|
},
|
|
}),
|
|
FlagsModule,
|
|
],
|
|
controllers: [HealthController],
|
|
})
|
|
export class AppModule {}
|