Skip to content

feat: poc pdp retrieval #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: nhaimerl-poc-pdp-repo-setup
Choose a base branch
from

Conversation

NikolasHaimerl
Copy link
Contributor

@NikolasHaimerl NikolasHaimerl commented May 21, 2025

Summary

This PR introduces the initial implementation of the PDP Checker tool for downloading files based on Content Identifiers (CIDs).

Changes

  1. Core Functionality:

    • Implemented retrieveFile for fetching files with retry logic.
  2. Testing:

    • Added unit and integration tests for retrieval and CID validation.

Closes #3

@NikolasHaimerl NikolasHaimerl marked this pull request as ready for review May 21, 2025 21:42
Copy link

@pyropy pyropy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff, there's only few small things to take care of before we merge it.

lib/retrieval.js Outdated
@@ -0,0 +1,48 @@
import fetch from 'node-fetch'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for using node-fetch as fetch is part of the standard library for node versions 18+ (we're using 22).

@@ -0,0 +1,48 @@
import fetch from 'node-fetch'
import pRetry from 'p-retry'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's aweesome that you've added p-retry 👍🏻

const testFilePath = path.join(__dirname, 'testData.pdf')
const testData = await fs.readFile(testFilePath)

const expectedHash = createHash('sha256').update(testData).digest('hex')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can save expectedHash as a constant rather then computing it for every time we run this test. This could also enable us to remove the testData.pdf file from the repository.

@NikolasHaimerl NikolasHaimerl changed the title Nhaimerl poc pdp retrieval feat: poc pdp retrieval May 22, 2025
@NikolasHaimerl NikolasHaimerl marked this pull request as draft May 22, 2025 11:59
@NikolasHaimerl NikolasHaimerl requested a review from pyropy May 22, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants