UNPKG

digitaltwin-core

Version:

Minimalist framework to collect and handle data in a Digital Twin project

36 lines 1.35 kB
/** * Factory class for creating the appropriate StorageService * implementation based on environment configuration. */ import { Env } from '../env/env.js'; import { OvhS3StorageService } from './adapters/ovh_storage_service.js'; import { LocalStorageService } from './adapters/local_storage_service.js'; export class StorageServiceFactory { /** * Creates and returns an instance of StorageService * based on the STORAGE_CONFIG environment variable. * * - 'local': returns a LocalStorageService * - 'ovh': returns an OvhS3StorageService * * @throws Error if STORAGE_CONFIG is not supported */ static create() { const env = Env.config; switch (env.STORAGE_CONFIG) { case 'local': return new LocalStorageService(env.LOCAL_STORAGE_DIR || 'data'); case 'ovh': return new OvhS3StorageService({ accessKey: env.OVH_ACCESS_KEY, secretKey: env.OVH_SECRET_KEY, endpoint: env.OVH_ENDPOINT, bucket: env.OVH_BUCKET, region: env.OVH_REGION ?? 'gra' }); default: throw new Error(`Unsupported STORAGE_CONFIG: ${env.STORAGE_CONFIG}`); } } } //# sourceMappingURL=storage_factory.js.map