-
Notifications
You must be signed in to change notification settings - Fork 7
fix: getProviders recognizes application/json accept header #155
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
Conversation
Thanks for opening this. Please can you run ‘npm run lint -- --fix’ to reformat your changes according to the existing linting rules. |
@achingbrain sure |
@achingbrain Done✅ |
Several files have many whitespace changes also. Please revert these changes, they just add noise to the PR and make it harder to review. |
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 are multiple edits to code that doesn't seem like anything has changed other than style/lint fixes from a tool other than eslint/aegir and our eslint-config-ipfs rules.
those should definitely be addressed so we can determine what actual code changes were made.
const providers = [ | ||
{ | ||
Protocol: 'transport-bitswap', | ||
Schema: 'bitswap', | ||
Metadata: 'gBI=', | ||
ID: (await generateKeyPair('Ed25519')).publicKey.toString(), | ||
Addrs: ['/ip4/41.41.41.41/tcp/1234'] | ||
}, | ||
{ | ||
Protocol: 'transport-bitswap', | ||
Schema: 'peer', | ||
Metadata: 'gBI=', | ||
ID: (await generateKeyPair('Ed25519')).publicKey.toString(), | ||
Addrs: ['/ip4/42.42.42.42/tcp/1234'] | ||
}, | ||
{ | ||
ID: (await generateKeyPair('Ed25519')).publicKey.toString(), | ||
Addrs: ['/ip4/43.43.43.43/tcp/1234'] | ||
} | ||
] |
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 looks like this change is style only, and unnecessary.
I would highly recommend disabling editorconfig and auto styling that is not using eslint
or aegir. If you disable auto-save, you should be able to run npm run lint -- --fix
to fix issues until you get your editor to a good place.
FYI: my editor is vscode, and I have https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint installed
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.
alryt thanks for the guidance. Will do it as desired
thanks @SgtPooki @achingbrain for the review and advice---
kindly look into it and provide guidance. |
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.
partial review because it still seems like a lot of stylistic and unnecessary changes were made
packages/client/.aegir.js
Outdated
@@ -1,96 +1,200 @@ | |||
import EchoServer from 'aegir/echo-server' | |||
import body from 'body-parser' | |||
import EchoServer from "aegir/echo-server"; |
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.
need to remove stylistic changes here and in the rest of the PR.
You might need to git checkout main -- <pathToFile>
and then discard everything except the changes that are needed.
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.
okay! lemme try it out👍
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.
this file still has a lot of single quotes changed to double quote, and semicolons added...
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.
i cannot understand, despite disabling autosave, eslint, why extra spaces, semicolons and double quotes are added. can you please guide me how to configure my vs-setup--I have downloaded this vsc extension--https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint--and then ran npm run lint -- --fix
, even did git checkout main --, and tried minimal code changes, yet
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.
so, from the root of the project, because this is a monorepo, you actually have to run npm run lint -- -- --fix
packages/client/.aegir.js
Outdated
next(); | ||
lastCalledUrl = req.url; | ||
}); | ||
// echo.polka.post("/add-providers/:cid", (req, res) => { |
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.
delete?
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.
yeah!
packages/client/test/index.spec.ts
Outdated
client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl), { cacheTTL: 0 }) | ||
client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl), { | ||
cacheTTL: 0 | ||
}) |
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.
unnecessary edit?
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.
yes it is irrelevant, my apology
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.
this one still needs addressed
packages/client/test/index.spec.ts
Outdated
await fetch(`${process.env.ECHO_SERVER}/add-providers/${cid.toString()}`, { | ||
method: 'POST', | ||
body: providers.map(prov => JSON.stringify(prov)).join('\n') | ||
}) | ||
await fetch( | ||
`${process.env.ECHO_SERVER}/add-providers/${cid.toString()}`, | ||
{ | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ Providers: providers }) | ||
} | ||
) |
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.
unnecessary formatting change?
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.
No, the test case was returning err when headers wasnt added here!
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.
Sure, but there are still formatting changes here that aren't necessary. e.g. we should still have await fetch(
${process.env.ECHO_SERVER}/add-providers/${cid.toString()}, {
on the initial line here AFAIK.
@achingbrain @SgtPooki |
Kindly review it. |
packages/client/.aegir.js
Outdated
@@ -1,96 +1,200 @@ | |||
import EchoServer from 'aegir/echo-server' | |||
import body from 'body-parser' | |||
import EchoServer from "aegir/echo-server"; |
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.
this file still has a lot of single quotes changed to double quote, and semicolons added...
packages/client/test/index.spec.ts
Outdated
import { | ||
createDelegatedRoutingV1HttpApiClient, | ||
type DelegatedRoutingV1HttpApiClient | ||
} from '../src/index.js' |
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.
another unnecessary change
import { | |
createDelegatedRoutingV1HttpApiClient, | |
type DelegatedRoutingV1HttpApiClient | |
} from '../src/index.js' | |
import { createDelegatedRoutingV1HttpApiClient, type DelegatedRoutingV1HttpApiClient } from '../src/index.js' |
packages/client/test/index.spec.ts
Outdated
client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl), { cacheTTL: 0 }) | ||
client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl), { | ||
cacheTTL: 0 | ||
}) |
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.
this one still needs addressed
@SgtPooki |
Kindly guide further? |
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.
I modified the code a bit.. lgtm now.
## [@helia/delegated-routing-v1-http-api-client-v4.2.2](https://github.com/ipfs/helia-delegated-routing-v1-http-api/compare/@helia/delegated-routing-v1-http-api-client-4.2.1...@helia/delegated-routing-v1-http-api-client-4.2.2) (2025-02-11) ### Bug Fixes * getProviders recognizes application/json accept header ([#155](#155)) ([8fd603b](8fd603b))
🎉 This PR is included in version @helia/delegated-routing-v1-http-api-client-v4.2.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
fix: content routing provider data handling and test cases
Description
Fixed the content routing implementation to ensure proper handling of provider data and JSON content types. All test cases are now passing across different environments (Node.js, Browser, WebWorker).
Key improvements:
Content-Type: application/json
headersTest Results:
Note: The 2 pending tests are related to cache TTL functionality, which is expected behavior.
Notes & open questions
None - all test cases are passing as expected across environments.
Change checklist