chore: update copyright years
[e-mobility-charging-stations-simulator.git] / src / performance / storage / StorageFactory.ts
CommitLineData
a19b897d 1// Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
c27c3eee 2
66a7748d 3import { JsonFileStorage } from './JsonFileStorage.js'
e1d9a0f4 4// eslint-disable-next-line @typescript-eslint/no-unused-vars
66a7748d
JB
5import { MikroOrmStorage } from './MikroOrmStorage.js'
6import { MongoDBStorage } from './MongoDBStorage.js'
7import type { Storage } from './Storage.js'
8import { BaseError } from '../../exception/index.js'
9import { StorageType } from '../../types/index.js'
72f041bd 10
66a7748d 11// eslint-disable-next-line @typescript-eslint/no-extraneous-class
72f041bd 12export class StorageFactory {
66a7748d 13 private constructor () {
6c3cfef8
JB
14 // This is intentional
15 }
72f041bd 16
66a7748d 17 public static getStorage (
6d2b7d01
JB
18 type: StorageType,
19 connectionUri: string,
66a7748d 20 logPrefix: string
6d2b7d01 21 ): Storage | undefined {
66a7748d 22 let storageInstance: Storage
72f041bd
JB
23 switch (type) {
24 case StorageType.JSON_FILE:
66a7748d
JB
25 storageInstance = new JsonFileStorage(connectionUri, logPrefix)
26 break
72f041bd 27 case StorageType.MONGO_DB:
66a7748d
JB
28 storageInstance = new MongoDBStorage(connectionUri, logPrefix)
29 break
a6b3c6c3
JB
30 // case StorageType.MYSQL:
31 // case StorageType.MARIA_DB:
32 // case StorageType.SQLITE:
66a7748d
JB
33 // storageInstance = new MikroOrmStorage(connectionUri, logPrefix, type)
34 // break
72f041bd 35 default:
66a7748d 36 throw new BaseError(`${logPrefix} Unknown storage type: ${type}`)
72f041bd 37 }
66a7748d 38 return storageInstance
72f041bd
JB
39 }
40}