Skip to content
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

feat: support 'create' constructor from ipfs-http-client #38

Merged
merged 2 commits into from
Sep 1, 2021

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Aug 24, 2021

This uses the new constructor from js-ipfs (introduced for improved typescript experience) but will fallback to the old way, making it backward-compatible with older js-ipfs versions -- @lidel

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
@hacdias hacdias requested a review from lidel August 24, 2021 09:17
@hacdias hacdias changed the title breaking: http-client expected to have .create fn breaking: http-client expected to export 'create' fn Aug 24, 2021
@@ -61,7 +61,7 @@ async function tryHttpClient ({ loadHttpClientModule, apiAddress, root, connecti
// Returns js-ipfs-http-client instance or null
async function maybeApi ({ apiAddress, connectionTest, httpClient, ...options }) {
try {
const ipfs = httpClient({ ...options, ...clientOptions(apiAddress) })
const ipfs = httpClient.create({ ...options, ...clientOptions(apiAddress) })
Copy link
Member

Choose a reason for hiding this comment

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

A bit unfortunate that this will break old code in demos and hackpads that naively load the latest version:

<script src="https://cdn.jsdelivr.net/npm/ipfs-core/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ipfs-http-client/dist/index.min.js"></script>

Can we add the old version inside the catch block, as a fallback attempt?
(ipfs-provider aims to smooth out rough edges introduced by breaking changes in js-ipfs*)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. It's now backwards compatible!

@hacdias hacdias changed the title breaking: http-client expected to export 'create' fn feat: http-client expected to export 'create' fn Sep 1, 2021
@hacdias hacdias requested a review from lidel September 1, 2021 10:41
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thanks! Will release soon.

@lidel lidel changed the title feat: http-client expected to export 'create' fn feat: support 'create' constructor from ipfs-http-client Sep 1, 2021
@lidel lidel merged commit df7b9b3 into master Sep 1, 2021
@lidel lidel deleted the feat/http-client-create branch September 1, 2021 16:12
@lidel
Copy link
Member

lidel commented Sep 1, 2021

Shipped in v2.1.0

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.

None yet

2 participants