diff --git a/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts b/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts index 6931c4e9..32203d4a 100644 --- a/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/FileMetadataRepository.ts @@ -7,11 +7,9 @@ const UTF8 = "utf8"; export class FileMetadataRepository implements MetadataRepository, StaticStrategy { private readonly dirPath: string; - private readonly cfg: Config; - constructor(cfg: Config) { - this.cfg = cfg; - this.dirPath = this.cfg.metadata?.dir!; + constructor(dirPath: string) { + this.dirPath = dirPath; if (!fs.existsSync(this.dirPath)) { fs.mkdirSync(this.dirPath, { recursive: true }); @@ -19,7 +17,7 @@ export class FileMetadataRepository implements MetadataRepository, StaticSt } apply(): boolean { - return this.cfg.metadata?.dir != undefined; + return this.dirPath != undefined; } getName(): string { @@ -27,7 +25,7 @@ export class FileMetadataRepository implements MetadataRepository, StaticSt } createInstance() { - return new FileMetadataRepository(this.cfg); + return new FileMetadataRepository(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 d7be07ea..a34a8fca 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.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 69e68598..b2193fd4 100644 --- a/blockchain-watcher/src/infrastructure/repositories/strategies/RepositoriesStrategy.ts +++ b/blockchain-watcher/src/infrastructure/repositories/strategies/RepositoriesStrategy.ts @@ -23,7 +23,7 @@ export class RepositoriesStrategy { const repositories: StaticStrategy[] = [ new SnsEventRepository(this.snsClient!, this.cfg), - new FileMetadataRepository(this.cfg), + new FileMetadataRepository(this.cfg.metadata!.dir!), new PromStatRepository(), ];