import Container, { Service } from 'typedi'; import { AccountsImportable } from './AccountsImportable'; import { ImportableRegistry } from './ImportableRegistry'; @Service() export class ImportableResources { private static registry: ImportableRegistry; constructor() { this.boot(); } /** * Importable instances. */ private importables = [ { resource: 'Account', importable: AccountsImportable }, ]; public get registry() { return ImportableResources.registry; } /** * Boots all the registered importables. */ public boot() { if (!ImportableResources.registry) { const instance = ImportableRegistry.getInstance(); this.importables.forEach((importable) => { const importableInstance = Container.get(importable.importable); instance.registerImportable(importable.resource, importableInstance); }); ImportableResources.registry = instance; } } }