81 lines
2.8 KiB
TypeScript
Executable file
81 lines
2.8 KiB
TypeScript
Executable file
// attributes-api: Attribute definitions and values management API
|
|
// Provides EAV (Entity-Attribute-Value) system for flexible user/entity attributes
|
|
|
|
import { join, dirname } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
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 { AttributesModule } from './attributes.module'
|
|
import { HealthController } from './health/health.controller';
|
|
import { SeedOnStartupService } from './seeds/seed-on-startup.service';
|
|
import { AttributeDefinition } from './entities/attribute-definition.entity';
|
|
import { CategoryImageSemantics } from './entities/category-image-semantics.entity';
|
|
import { FilterSemanticOverride } from './entities/filter-semantic-override.entity';
|
|
|
|
// Build deployment registry - paths resolved via LILITH_PROJECT_ROOT env var
|
|
// Start services via ./run dev to ensure env var is set
|
|
// DISABLED for showcase: Deployment registry not needed for local dev
|
|
// 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 attributes shared service's PostgreSQL
|
|
TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: async (config: ConfigService) => {
|
|
// SHOWCASE: Using localhost defaults instead of service registry
|
|
// const dbService = registry.services.get('attributes.postgresql')
|
|
|
|
return {
|
|
type: 'postgres',
|
|
host: 'localhost',
|
|
port: parseInt(config.get('DATABASE_POSTGRES_PORT', '25432'), 10),
|
|
username: config.get('DATABASE_POSTGRES_USER', 'lilith'),
|
|
password: config.get('DATABASE_POSTGRES_PASSWORD', 'lilith'),
|
|
database: config.get('DATABASE_POSTGRES_NAME', 'lilith'),
|
|
autoLoadEntities: true,
|
|
synchronize: false,
|
|
logging: config.get('NODE_ENV') !== 'production',
|
|
retryAttempts: 10,
|
|
retryDelay: 2000,
|
|
}
|
|
},
|
|
}),
|
|
|
|
// Feature modules
|
|
AttributesModule,
|
|
|
|
// Entity repositories for auto-seed service
|
|
TypeOrmModule.forFeature([
|
|
AttributeDefinition,
|
|
CategoryImageSemantics,
|
|
FilterSemanticOverride,
|
|
]),
|
|
],
|
|
controllers: [HealthController],
|
|
providers: [SeedOnStartupService],
|
|
})
|
|
export class AppModule {}
|