1 import { JSONFileStorage
} from
'./JSONFileStorage';
2 import { MongoDBStorage
} from
'./MongoDBStorage';
3 import { Storage
} from
'./Storage';
4 import { StorageType
} from
'../../types/Storage';
6 export class StorageFactory
{
7 // eslint-disable-next-line @typescript-eslint/no-empty-function
8 private constructor() {
12 public static getStorage(type: StorageType
, connectionURI
: string, logPrefix
: string): Storage
{
13 let storageInstance
: Storage
= null;
15 case StorageType
.JSON_FILE
:
16 storageInstance
= new JSONFileStorage(connectionURI
, logPrefix
);
18 case StorageType
.MONGO_DB
:
19 storageInstance
= new MongoDBStorage(connectionURI
, logPrefix
);
22 throw new Error(`${logPrefix} Unknown storage type: ${type}`);
24 return storageInstance
;