build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / src / performance / storage / StorageFactory.ts
CommitLineData
edd13439 1// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
c27c3eee 2
c1565026 3import { JsonFileStorage } from './JsonFileStorage';
e1d9a0f4 4// eslint-disable-next-line @typescript-eslint/no-unused-vars
c1565026
JB
5import { MikroOrmStorage } from './MikroOrmStorage';
6import { MongoDBStorage } from './MongoDBStorage';
7import type { Storage } from './Storage';
7b5dbe91 8import { BaseError } from '../../exception';
268a74bb 9import { StorageType } from '../../types';
72f041bd
JB
10
11export class StorageFactory {
6c3cfef8
JB
12 private constructor() {
13 // This is intentional
14 }
72f041bd 15
1f5df42a 16 public static getStorage(type: StorageType, connectionUri: string, logPrefix: string): Storage {
1895299d 17 let storageInstance: Storage | null = null;
72f041bd
JB
18 switch (type) {
19 case StorageType.JSON_FILE:
100a5301 20 storageInstance = new JsonFileStorage(connectionUri, logPrefix);
72f041bd
JB
21 break;
22 case StorageType.MONGO_DB:
1f5df42a 23 storageInstance = new MongoDBStorage(connectionUri, logPrefix);
72f041bd 24 break;
a6b3c6c3
JB
25 // case StorageType.MYSQL:
26 // case StorageType.MARIA_DB:
27 // case StorageType.SQLITE:
7f61131f 28 // storageInstance = new MikroOrmStorage(connectionUri, logPrefix, type);
a6b3c6c3 29 // break;
72f041bd 30 default:
7b5dbe91 31 throw new BaseError(`${logPrefix} Unknown storage type: ${type}`);
72f041bd
JB
32 }
33 return storageInstance;
34 }
35}