-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: nhaimerl-poc-pdp-repo-setup
Are you sure you want to change the base?
feat: poc pdp retrieval #8
Conversation
There was a problem hiding this 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' |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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
👍🏻
test/retrieval_tests.js
Outdated
const testFilePath = path.join(__dirname, 'testData.pdf') | ||
const testData = await fs.readFile(testFilePath) | ||
|
||
const expectedHash = createHash('sha256').update(testData).digest('hex') |
There was a problem hiding this comment.
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.
Summary
This PR introduces the initial implementation of the PDP Checker tool for downloading files based on Content Identifiers (CIDs).
Changes
Core Functionality:
retrieveFile
for fetching files with retry logic.Testing:
Closes #3