From 18dd1870ad0d4c74f24ca88cbd7ba0cd77848cd7 Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:45:04 +0000 Subject: [PATCH] add dpid env var for pdf cover generations --- desci-media-isolated/.env.example | 4 +++- desci-media-isolated/kubernetes/deployment_dev.yaml | 2 ++ desci-media-isolated/kubernetes/deployment_prod.yaml | 2 ++ desci-media-isolated/kubernetes/deployment_staging.yaml | 2 ++ desci-media-isolated/src/services/pdf.ts | 4 +++- desci-server/src/services/PublishPackage.ts | 5 +++-- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/desci-media-isolated/.env.example b/desci-media-isolated/.env.example index d61e65e5..c9641f6d 100644 --- a/desci-media-isolated/.env.example +++ b/desci-media-isolated/.env.example @@ -2,4 +2,6 @@ NODE_ENV=development PORT=7771 -IPFS_GATEWAY=http://host.docker.internal:5420/v1/ipfs \ No newline at end of file +IPFS_GATEWAY=http://host.docker.internal:5420/v1/ipfs + +DPID_RESOLVER_URL=https://dev-beta.dpid.org \ No newline at end of file diff --git a/desci-media-isolated/kubernetes/deployment_dev.yaml b/desci-media-isolated/kubernetes/deployment_dev.yaml index cf2b6ae0..497faf8b 100644 --- a/desci-media-isolated/kubernetes/deployment_dev.yaml +++ b/desci-media-isolated/kubernetes/deployment_dev.yaml @@ -46,6 +46,8 @@ spec: value: '7771' - name: IPFS_GATEWAY value: 'https://ipfs.desci.com/ipfs' + - name: DPID_RESOLVER_URL + value: 'https://dev-beta.dpid.org' resources: limits: cpu: '4' diff --git a/desci-media-isolated/kubernetes/deployment_prod.yaml b/desci-media-isolated/kubernetes/deployment_prod.yaml index 3909e505..e1b3180d 100644 --- a/desci-media-isolated/kubernetes/deployment_prod.yaml +++ b/desci-media-isolated/kubernetes/deployment_prod.yaml @@ -46,6 +46,8 @@ spec: value: '7771' - name: IPFS_GATEWAY value: 'http://host.docker.internal:5420/v1/ipfs' + - name: DPID_RESOLVER_URL + value: 'https://beta.dpid.org' resources: limits: cpu: '0.5' diff --git a/desci-media-isolated/kubernetes/deployment_staging.yaml b/desci-media-isolated/kubernetes/deployment_staging.yaml index 1da4834b..e92bf4dc 100644 --- a/desci-media-isolated/kubernetes/deployment_staging.yaml +++ b/desci-media-isolated/kubernetes/deployment_staging.yaml @@ -46,6 +46,8 @@ spec: value: '7771' - name: IPFS_GATEWAY value: 'http://host.docker.internal:5420/v1/ipfs' + - name: DPID_RESOLVER_URL + value: 'https://dev-beta.dpid.org' resources: limits: cpu: '0.5' diff --git a/desci-media-isolated/src/services/pdf.ts b/desci-media-isolated/src/services/pdf.ts index 0dffc5f9..48c374af 100644 --- a/desci-media-isolated/src/services/pdf.ts +++ b/desci-media-isolated/src/services/pdf.ts @@ -85,8 +85,10 @@ export class PdfManipulationService { /* * Header */ + const dpidResolverUrl = process.env.DPID_RESOLVER_URL ?? 'https://beta.dpid.org'; + const licenseStartsWithVowel = startsWithVowel(license); - const nodeUrl = usingDoi ? `https://doi.org/${doi}` : `https://beta.dpid.org/${dpid}`; + const nodeUrl = usingDoi ? `https://doi.org/${doi}` : `${dpidResolverUrl}/${dpid}`; const topHeader = `Research object ${nodeUrl}, this version posted ${publishDate}. The copyright holder for this research object (which was not certified by peer review) is the author/funder, who has granted DeSci Labs a non-exclsuive license to display the research object in perpetuity. It is made available under a${ licenseStartsWithVowel ? 'n' : '' } ${license} license.`; diff --git a/desci-server/src/services/PublishPackage.ts b/desci-server/src/services/PublishPackage.ts index d4987efb..9e9019f5 100644 --- a/desci-server/src/services/PublishPackage.ts +++ b/desci-server/src/services/PublishPackage.ts @@ -73,12 +73,13 @@ class PublishPackageService { const openCodeAttestation = attestations.find((a) => a.attestationVersion.name === 'Open Code'); const openDataAttestation = attestations.find((a) => a.attestationVersion.name === 'Open Data'); + const dpidUrl = process.env.DPID_URL_OVERRIDE ?? 'https://beta.dpid.org'; const attestationLinks = { ...(openCodeAttestation && { - codeAvailableDpid: `https://beta.dpid.org/${dpid}/attestations/${toKebabCase(openCodeAttestation.attestationVersion.name)}`, + codeAvailableDpid: `${dpidUrl}/${dpid}/attestations/${toKebabCase(openCodeAttestation.attestationVersion.name)}`, }), ...(openDataAttestation && { - dataAvailableDpid: `https://beta.dpid.org/${dpid}/attestations/${toKebabCase(openDataAttestation.attestationVersion.name)}`, + dataAvailableDpid: `${dpidUrl}/${dpid}/attestations/${toKebabCase(openDataAttestation.attestationVersion.name)}`, }), };