mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-12 19:00:31 +00:00
40 lines
946 B
TypeScript
40 lines
946 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|