import { Injectable } from '@nestjs/common';

export type AdminModuleInfo = {
  key: string;
  name: string;
  description?: string;
  routePrefix?: string;
  version?: string;
};

@Injectable()
export class ModuleRegistryService {
  private modules: AdminModuleInfo[] = [];

  registerModule(info: AdminModuleInfo) {
    if (!this.modules.find((m) => m.key === info.key)) {
      this.modules.push(info);
    }
  }

  getModules(): AdminModuleInfo[] {
    return [...this.modules];
  }
}
