StoragesModule.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. import { ContainerModule, interfaces } from 'inversify';
  2. import { ServiceIdentifiers } from '../../ServiceIdentifiers';
  3. import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
  4. import { ICustomNodeGroup } from '../../../interfaces/custom-nodes/ICustomNodeGroup';
  5. import { IStorage } from '../../../interfaces/storages/IStorage';
  6. import { ControlFlowStorage } from '../../../storages/control-flow/ControlFlowStorage';
  7. import { CustomNodeGroupStorage } from '../../../storages/custom-node-group/CustomNodeGroupStorage';
  8. import { StringArrayStorage } from '../../../storages/string-array/StringArrayStorage';
  9. export const storagesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
  10. // storages
  11. bind<IStorage<ICustomNodeGroup>>(ServiceIdentifiers['IStorage<ICustomNodeGroup>'])
  12. .to(CustomNodeGroupStorage)
  13. .inSingletonScope();
  14. bind<IStorage<ICustomNode>>(ServiceIdentifiers['IStorage<ICustomNode>'])
  15. .to(ControlFlowStorage);
  16. bind<IStorage<string>>(ServiceIdentifiers['IStorage<string>'])
  17. .to(StringArrayStorage)
  18. .inSingletonScope();
  19. // controlFlowStorage factory
  20. bind<IStorage<ICustomNode>>(ServiceIdentifiers['Factory<IStorage<ICustomNode>>'])
  21. .toFactory<IStorage<ICustomNode>>((context: interfaces.Context) => {
  22. return () => {
  23. return context.container.get<IStorage<ICustomNode>>(ServiceIdentifiers['IStorage<ICustomNode>']);
  24. };
  25. });
  26. });