diff --git a/docs/api/classes/modules_did_did_processor.DIDProcessor.md b/docs/api/classes/modules_did_did_processor.DIDProcessor.md index 1575ee54..aa8885f4 100644 --- a/docs/api/classes/modules_did_did_processor.DIDProcessor.md +++ b/docs/api/classes/modules_did_did_processor.DIDProcessor.md @@ -31,7 +31,7 @@ | `didService` | [`DIDService`](modules_did_did_service.DIDService.md) | | `logger` | [`Logger`](modules_logger_logger_service.Logger.md) | | `configService` | `ConfigService`<`Record`<`string`, `unknown`\>, ``false``\> | -| `pinQueue` | `Queue`<`any`\> | +| `pinQueue` | `Queue`<[`PinClaimData`](../modules/modules_ipfs_ipfs_types.md#pinclaimdata)\> | ## Methods diff --git a/docs/api/classes/modules_ipfs_ipfs_service.IPFSService.md b/docs/api/classes/modules_ipfs_ipfs_service.IPFSService.md index d8395feb..a1410f81 100644 --- a/docs/api/classes/modules_ipfs_ipfs_service.IPFSService.md +++ b/docs/api/classes/modules_ipfs_ipfs_service.IPFSService.md @@ -26,7 +26,7 @@ | :------ | :------ | | `didStoreCluster` | `DidStore` | | `didStoreInfura` | `DidStore` | -| `pinsQueue` | `Queue`<`string`\> | +| `pinsQueue` | `Queue`<[`PinClaimData`](../modules/modules_ipfs_ipfs_types.md#pinclaimdata)\> | | `logger` | [`Logger`](modules_logger_logger_service.Logger.md) | ## Methods diff --git a/docs/api/classes/modules_ipfs_pin_processor.PinProcessor.md b/docs/api/classes/modules_ipfs_pin_processor.PinProcessor.md index a40ea1fa..d45a9290 100644 --- a/docs/api/classes/modules_ipfs_pin_processor.PinProcessor.md +++ b/docs/api/classes/modules_ipfs_pin_processor.PinProcessor.md @@ -108,7 +108,7 @@ It was implemented for EW migration from Infura to EW hosted IPFS | Name | Type | | :------ | :------ | -| `job` | `Job`<`any`\> | +| `job` | `Job`<[`PinClaimData`](../modules/modules_ipfs_ipfs_types.md#pinclaimdata)\> | #### Returns diff --git a/docs/api/modules/modules_ipfs_ipfs_types.md b/docs/api/modules/modules_ipfs_ipfs_types.md index 333e8e9a..c3dc9f9c 100644 --- a/docs/api/modules/modules_ipfs_ipfs_types.md +++ b/docs/api/modules/modules_ipfs_ipfs_types.md @@ -6,6 +6,7 @@ - [IpfsClusterConfig](modules_ipfs_ipfs_types.md#ipfsclusterconfig) - [IpfsInfuraConfig](modules_ipfs_ipfs_types.md#ipfsinfuraconfig) +- [PinClaimData](modules_ipfs_ipfs_types.md#pinclaimdata) ### Variables @@ -38,6 +39,19 @@ ___ | `protocol?` | `string` | | `url?` | `string` | +___ + +### PinClaimData + +Ƭ **PinClaimData**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `cid` | `string` | +| `claim?` | `string` | + ## Variables ### IPFSClusterConfigToken diff --git a/src/modules/did/did.processor.ts b/src/modules/did/did.processor.ts index 93ae15ac..947e609c 100644 --- a/src/modules/did/did.processor.ts +++ b/src/modules/did/did.processor.ts @@ -10,7 +10,11 @@ import { } from '@nestjs/bull'; import { ConfigService } from '@nestjs/config'; import { Job, Queue } from 'bull'; -import { PIN_CLAIM_JOB_NAME, PIN_CLAIM_QUEUE_NAME } from '../ipfs/ipfs.types'; +import { + PinClaimData, + PIN_CLAIM_JOB_NAME, + PIN_CLAIM_QUEUE_NAME, +} from '../ipfs/ipfs.types'; import { Logger } from '../logger/logger.service'; import { DIDDocumentEntity } from './did.entity'; import { DIDService } from './did.service'; @@ -27,7 +31,7 @@ export class DIDProcessor { private readonly logger: Logger, private readonly configService: ConfigService, @InjectQueue(PIN_CLAIM_QUEUE_NAME) - private pinQueue: Queue + private pinQueue: Queue ) { this.logger.setContext(DIDProcessor.name); } diff --git a/src/modules/ipfs/ipfs.service.ts b/src/modules/ipfs/ipfs.service.ts index 50e64756..14035e71 100644 --- a/src/modules/ipfs/ipfs.service.ts +++ b/src/modules/ipfs/ipfs.service.ts @@ -4,7 +4,11 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { CID } from 'multiformats/cid'; import { InjectQueue } from '@nestjs/bull'; import { Queue } from 'bull'; -import { PIN_CLAIM_QUEUE_NAME, PIN_CLAIM_JOB_NAME } from './ipfs.types'; +import { + PIN_CLAIM_QUEUE_NAME, + PIN_CLAIM_JOB_NAME, + PinClaimData, +} from './ipfs.types'; import { Logger } from '../logger/logger.service'; import { inspect } from 'util'; @@ -14,7 +18,7 @@ export class IPFSService { private didStoreCluster: DidStoreCluster, private didStoreInfura: DidStoreGateway, @InjectQueue(PIN_CLAIM_QUEUE_NAME) - private readonly pinsQueue: Queue, + private readonly pinsQueue: Queue, private readonly logger: Logger ) { this.logger.setContext(IPFSService.name); @@ -64,10 +68,7 @@ export class IPFSService { } try { - await this.pinsQueue.add( - PIN_CLAIM_JOB_NAME, - JSON.stringify({ cid, claim }) - ); + await this.pinsQueue.add(PIN_CLAIM_JOB_NAME, { cid, claim }); } catch (e) { this.logger.debug(`Error to add pin job for cid ${cid}: ${e}`); const jobsCounts = await this.pinsQueue.getJobCounts(); diff --git a/src/modules/ipfs/ipfs.types.ts b/src/modules/ipfs/ipfs.types.ts index c0015dba..7dbfc166 100644 --- a/src/modules/ipfs/ipfs.types.ts +++ b/src/modules/ipfs/ipfs.types.ts @@ -19,3 +19,8 @@ export const IPFSClusterConfigToken = Symbol.for('IPFSClusterConfigToken'); export const PIN_CLAIM_JOB_NAME = 'pinning'; export const PIN_CLAIM_QUEUE_NAME = 'pinClaimQueue'; + +export type PinClaimData = { + cid: string; + claim?: string; +}; diff --git a/src/modules/ipfs/pin.processor.ts b/src/modules/ipfs/pin.processor.ts index 1012e787..7ec4a0b7 100644 --- a/src/modules/ipfs/pin.processor.ts +++ b/src/modules/ipfs/pin.processor.ts @@ -10,7 +10,11 @@ import { Job } from 'bull'; import { DidStore as DidStoreInfura } from 'didStoreInfura'; import { DidStore as DidStoreCluster } from 'didStoreCluster'; import { Logger } from '../logger/logger.service'; -import { PIN_CLAIM_JOB_NAME, PIN_CLAIM_QUEUE_NAME } from './ipfs.types'; +import { + PinClaimData, + PIN_CLAIM_JOB_NAME, + PIN_CLAIM_QUEUE_NAME, +} from './ipfs.types'; @Processor(PIN_CLAIM_QUEUE_NAME) export class PinProcessor { @@ -49,10 +53,9 @@ export class PinProcessor { * It was implemented for EW migration from Infura to EW hosted IPFS */ @Process(PIN_CLAIM_JOB_NAME) - async pin(job: Job) { - const data = JSON.parse(job.data); - const cid = data.cid; - let claim = data.claim; + async pin(job: Job) { + const cid = job.data.cid; + let claim = job.data.claim; try { await this.didStoreCluster.get(cid); } catch (_) {