All files / src/container/modules/storages StoragesModule.ts

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