import { Logger, Module, OnModuleInit } from '@nestjs/common'; import { ModuleRegistryModule } from '../module-registry/module-registry.module'; import { ModuleRegistryService } from '../module-registry/module-registry.service'; import { CertManagerController } from './cert-manager.controller'; import { seedCertManagerModule } from './cert-manager.seed'; import { CertManagerService } from './cert-manager.service'; /** * NestJS module for the Cert Manager feature. * * Provides server-side certificate inspection, splitting, merging, * and format conversion using node-forge (pure JS, no native bindings). * * Seeds itself into the module registry on application startup via * OnModuleInit lifecycle hook (CERT-06). * * After seeding: an admin must activate the module per-tenant via the * Marketplace UI before endpoints become accessible (ModuleGuard checks * TenantModuleActivation, not isSystem flag — RESEARCH.md Pitfall 2). */ @Module({ imports: [ModuleRegistryModule], controllers: [CertManagerController], providers: [CertManagerService], }) export class CertManagerModule implements OnModuleInit { private readonly logger = new Logger(CertManagerModule.name); constructor( private readonly moduleRegistryService: ModuleRegistryService, ) {} async onModuleInit(): Promise { try { await seedCertManagerModule(this.moduleRegistryService); this.logger.log('Cert-Manager module seeded in registry'); } catch (error) { this.logger.error('Failed to seed cert-manager module', error); } } }