Add MongDB support to storage for performance records.
[e-mobility-charging-stations-simulator.git] / src / utils / performance-storage / StorageFactory.ts
CommitLineData
72f041bd
JB
1import { JSONFileStorage } from './JSONFileStorage';
2import { MongoDBStorage } from './MongoDBStorage';
3import { Storage } from './Storage';
4import { StorageType } from '../../types/Storage';
72f041bd
JB
5
6export class StorageFactory {
7 // eslint-disable-next-line @typescript-eslint/no-empty-function
6c3cfef8
JB
8 private constructor() {
9 // This is intentional
10 }
72f041bd
JB
11
12 public static getStorage(type: StorageType, connectionURI: string, logPrefix: string): Storage {
13 let storageInstance: Storage = null;
14 switch (type) {
15 case StorageType.JSON_FILE:
16 storageInstance = new JSONFileStorage(connectionURI, logPrefix);
17 break;
18 case StorageType.MONGO_DB:
19 storageInstance = new MongoDBStorage(connectionURI, logPrefix);
20 break;
21 default:
fb226c9b 22 throw new Error(`${logPrefix} Unknown storage type: ${type}`);
72f041bd
JB
23 }
24 return storageInstance;
25 }
26}