diff --git a/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts b/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts index 7b6c2259..5ca5aaa6 100644 --- a/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts @@ -9,9 +9,9 @@ export class FileMetadataRepository implements MetadataRepository, Reposito private readonly dirPath: string; private readonly cfg: Config; - constructor(cfg: Config) { + constructor(cfg: Config, dirPath: string) { this.cfg = cfg; - this.dirPath = this.cfg!.metadata!.dir; + this.dirPath = dirPath; if (!fs.existsSync(this.dirPath)) { fs.mkdirSync(this.dirPath, { recursive: true }); @@ -27,7 +27,7 @@ export class FileMetadataRepository implements MetadataRepository, Reposito } createInstance() { - return new FileMetadataRepository(this.cfg); + return new FileMetadataRepository(this.cfg, this.dirPath); } async get(id: string): Promise { diff --git a/blockchain-watcher/src/infrastructure/repositories/StaticJobRepository.ts b/blockchain-watcher/src/infrastructure/repositories/StaticJobRepository.ts index ae882a4b..359d2d6b 100644 --- a/blockchain-watcher/src/infrastructure/repositories/StaticJobRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/StaticJobRepository.ts @@ -45,7 +45,7 @@ export class StaticJobRepository implements JobRepository { solanaSlotRepo: SolanaSlotRepository; } ) { - this.fileRepo = new FileMetadataRepository(cfg); + this.fileRepo = new FileMetadataRepository(cfg, cfg.jobs.dir); this.blockRepoProvider = blockRepoProvider; this.metadataRepo = repos.metadataRepo; this.statsRepo = repos.statsRepo; diff --git a/blockchain-watcher/src/infrastructure/repositories/strategies/RepositoriesStrategy.ts b/blockchain-watcher/src/infrastructure/repositories/strategies/RepositoriesStrategy.ts index 17e455c2..4a85e599 100644 --- a/blockchain-watcher/src/infrastructure/repositories/strategies/RepositoriesStrategy.ts +++ b/blockchain-watcher/src/infrastructure/repositories/strategies/RepositoriesStrategy.ts @@ -20,7 +20,7 @@ export class RepositoriesStrategy { executeStatic(): Map { const repositories = [ new SnsEventRepository(this.snsClient!, this.cfg), - new FileMetadataRepository(this.cfg), + new FileMetadataRepository(this.cfg, this.cfg.metadata?.dir!), new PromStatRepository(), ]; diff --git a/blockchain-watcher/test/infrastructure/repositories/FileMetadataRepo.test.ts b/blockchain-watcher/test/infrastructure/repositories/FileMetadataRepo.test.ts index f6c440a3..2e8f7968 100644 --- a/blockchain-watcher/test/infrastructure/repositories/FileMetadataRepo.test.ts +++ b/blockchain-watcher/test/infrastructure/repositories/FileMetadataRepo.test.ts @@ -6,7 +6,7 @@ import { configMock } from "../../mock/configMock"; describe("FileMetadataRepository", () => { const dirPath = "./metadata-repo"; const cfg = configMock(); - const repo = new FileMetadataRepository(cfg); + const repo = new FileMetadataRepository(cfg, dirPath); beforeEach(() => { if (!fs.existsSync(dirPath)) {