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: add js-kubo-rpc-client #764

Merged
merged 28 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
20ea2f9
feat: add js-kubo-rpc-client
SgtPooki Aug 19, 2022
cb0e10b
chore: update kubo-rpc-client package name
SgtPooki Sep 6, 2022
7fa9e7e
fix: use cross-env to set USE_KUBO_JS
SgtPooki Sep 7, 2022
3b775f0
Merge branch 'ipfs:master' into feature/add-js-kubo-rpc-client
SgtPooki Sep 19, 2022
ee3b36a
fix: Remove USE_KUBO_JS env var
SgtPooki Sep 19, 2022
60c2c84
chore(deps): remove cross-env
SgtPooki Sep 20, 2022
004ebc6
docs(readme): update npm install cmds for using kubo-rpc-client
SgtPooki Sep 21, 2022
b828341
chore: log whether kubo-rpc-client or ipfs-http-client is in use
SgtPooki Sep 21, 2022
e4e8bb5
chore(tests): use kubo-rpc-client for commmunication with go controllers
SgtPooki Sep 21, 2022
3db2fb5
Merge branch 'master' into feature/add-js-kubo-rpc-client
SgtPooki Sep 21, 2022
ab88fed
chore(lint): fix lint failure
SgtPooki Sep 21, 2022
0ed3917
fix: addCorrectRpcModule returns the additionalOpts object
SgtPooki Sep 21, 2022
9eb0b51
docs(readme): correct kubo-rpc-client name
SgtPooki Sep 22, 2022
8de4a2d
fix: use correct logger namespace convention
SgtPooki Sep 22, 2022
68673b8
fix: move kubo-rpc-client to devDeps
SgtPooki Sep 22, 2022
48adc63
fix: support generics for Controller type
SgtPooki Sep 22, 2022
cb4c373
chore(deps): use kubo-rpc-client@1.0.1
SgtPooki Sep 23, 2022
5783286
feat!: convert to typescript
achingbrain Sep 29, 2022
2f98a0b
chore: fix linting
achingbrain Sep 30, 2022
3a78c13
chore: fix tests
achingbrain Sep 30, 2022
feadf53
Merge branch 'feature/add-js-kubo-rpc-client' into feat/convert-to-ty…
SgtPooki Sep 30, 2022
86aec67
chore: apply suggestions from code review
achingbrain Oct 1, 2022
919e03f
fix: resolve issues with js-kubo-rpc-client in typescript
SgtPooki Oct 3, 2022
0635198
fix: use kuboRpcModule for go in factory.spec.ts
SgtPooki Oct 3, 2022
d1fa4c0
Merge branch 'feat/convert-to-typescript' into feature/add-js-kubo-rp…
SgtPooki Oct 3, 2022
baa5ffb
chore: merge master
SgtPooki Oct 4, 2022
d3afe62
fix: broken build from bad merge
SgtPooki Oct 4, 2022
30db4db
chore: address PR comments
SgtPooki Oct 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createServer } from './src/index.js'
import * as ipfsModule from 'ipfs'
import * as ipfsHttpModule from 'ipfs-http-client'
import * as kuboRpcModule from 'kubo-rpc-client'
import * as goIpfsModule from 'go-ipfs'

/** @type {import('aegir').Options["build"]["config"]} */
Expand All @@ -20,10 +21,19 @@ export default {
}
},
before: async () => {
const server = createServer(undefined, {
ipfsModule,
ipfsHttpModule
}, {
/**
* @type {import('./src/types.js').ControllerOptions}
*/
let controllerOptions = {
ipfsModule,
}

if (process.env.USE_KUBO_JS) {
controllerOptions.kuboRpcModule = kuboRpcModule
} else {
controllerOptions.ipfsHttpModule = ipfsHttpModule
}
SgtPooki marked this conversation as resolved.
Show resolved Hide resolved
const server = createServer(undefined, controllerOptions, {
go: {
ipfsBin: goIpfsModule.path()
},
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@
"scripts": {
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:chrome": "aegir test -t browser",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test": "aegir test && cross-env USE_KUBO_JS=1 aegir test",
"test:node": "aegir test -t node && cross-env USE_KUBO_JS=1 aegir test -t node",
"test:chrome": "aegir test -t browser && cross-env USE_KUBO_JS=1 aegir test -t browser",
"test:firefox": "aegir test -t browser -- --browser firefox && cross-env USE_KUBO_JS=1 aegir test -t browser -- --browser firefox",
"release": "aegir release"
},
"dependencies": {
Expand All @@ -155,6 +155,7 @@
"execa": "^6.1.0",
"ipfs-utils": "^9.0.1",
"joi": "^17.2.1",
"kubo-rpc-client": "^1.0.0",
SgtPooki marked this conversation as resolved.
Show resolved Hide resolved
"merge-options": "^3.0.1",
"nanoid": "^4.0.0",
"p-wait-for": "^4.1.0",
Expand All @@ -164,6 +165,7 @@
"devDependencies": {
"@types/hapi__hapi": "^20.0.9",
"aegir": "^37.0.15",
"cross-env": "^7.0.3",
"go-ipfs": "^0.13.0",
"ipfs": "^0.63.5",
"ipfs-client": "^0.8.3",
Expand Down
3 changes: 2 additions & 1 deletion src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class Factory {
remote: false,
ipfsBin: undefined,
ipfsModule: undefined,
ipfsHttpModule: undefined
ipfsHttpModule: undefined,
kuboRpcModule: undefined
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/ipfsd-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ class Client {
http: this.apiAddr
})
} else if (this.apiAddr) {
this.api = this.opts.ipfsHttpModule.create(this.apiAddr)
if (this.opts.kuboRpcModule != null) {
this.api = this.opts.kuboRpcModule.create(this.apiAddr)
} else if (this.opts.ipfsHttpModule != null) {
this.api = this.opts.ipfsHttpModule.create(this.apiAddr)
} else {
throw new Error('You must pass either a kuboRpcModule or ipfsHttpModule')
}
}

if (this.api) {
Expand Down
8 changes: 7 additions & 1 deletion src/ipfsd-daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ class Daemon {
http: this.apiAddr
})
} else if (this.apiAddr) {
this.api = this.opts.ipfsHttpModule.create(this.apiAddr)
if (this.opts.kuboRpcModule != null) {
this.api = this.opts.kuboRpcModule.create(this.apiAddr)
} else if (this.opts.ipfsHttpModule != null) {
this.api = this.opts.ipfsHttpModule.create(this.apiAddr)
} else {
throw new Error('You must pass either a kuboRpcModule or ipfsHttpModule')
}
}

if (!this.api) {
Expand Down
9 changes: 8 additions & 1 deletion src/ipfsd-in-proc.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ class InProc {
*/
_setApi (addr) {
this.apiAddr = new Multiaddr(addr)
this.api = this.opts.ipfsHttpModule.create(addr)

if (this.opts.kuboRpcModule != null) {
this.api = this.opts.kuboRpcModule.create(addr)
} else if (this.opts.ipfsHttpModule != null) {
this.api = this.opts.ipfsHttpModule.create(addr)
} else {
throw new Error('You must pass either a kuboRpcModule or ipfsHttpModule')
}
this.api.apiHost = this.apiAddr.nodeAddress().address
this.api.apiPort = this.apiAddr.nodeAddress().port
}
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ export interface ControllerOptions {
* Reference to an ipfs-http-client module
*/
ipfsHttpModule?: any
/**
* Reference to a kubo-rpc-client module
*/
kuboRpcModule?: any
/**
* Reference to an ipfs or ipfs-core module
*/
Expand Down