Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
update deprecated ipfs-api package
Browse files Browse the repository at this point in the history
  • Loading branch information
Alaan Rahim committed Apr 25, 2019
1 parent 35c3c5c commit 00d061d
Show file tree
Hide file tree
Showing 8 changed files with 1,021 additions and 1,166 deletions.
4 changes: 2 additions & 2 deletions api/core/ipfs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ipfsAPI = require('ipfs-api')
const defaultIpfs = ipfsAPI(process.env.IPFS_HOST || '127.0.0.1')
const ipfsClient = require('ipfs-http-client')
const defaultIpfs = ipfsClient(process.env.IPFS_HOST || '127.0.0.1')

const add = async (data, ipfs = defaultIpfs) => {
const [ storedData ] = await ipfs.add(Buffer.from(data))
Expand Down
1,171 changes: 563 additions & 608 deletions api/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@appliedblockchain/b-privacy": "^1.2.0",
"@koa/cors": "^2.2.2",
"abi-decoder": "^1.2.0",
"ipfs-api": "^24.0.1",
"ipfs-http-client": "^30.1.3",
"koa": "^2.5.3",
"koa-compress": "^3.0.0",
"koa-joi-router": "^5.1.0",
Expand Down
12 changes: 6 additions & 6 deletions api/router/routes/ipfs/decorateCtx.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* Creates a koa middleware function that adds an instance of ipfs-api to the context
* Creates a koa middleware function that adds an instance of ipfs-http-client to the context
* @func module:mantle/api/router/routes/ipfs#decorateCtx
* @param {Object|String} ipfsApiOptions This will be used to instantiate a new instance of ipfs-api
* @param {Object|String} ipfsClientOptions This will be used to instantiate a new instance of ipfs-http-client
* @return {Function} Koa middleware
* @see https://koajs.com/
* @see https://www.npmjs.com/package/ipfs-api
* @see https://www.npmjs.com/package/ipfs-http-client
*/
const decorateCtx = (ipfsApiOptions = '127.0.0.1') => {
const ipfsAPI = require('ipfs-api')
const decorateCtx = (ipfsClientOptions = '127.0.0.1') => {
const ipfsClient = require('ipfs-http-client')

return async (ctx, next) => {
ctx.ipfs = ipfsAPI(ipfsApiOptions)
ctx.ipfs = ipfsClient(ipfsClientOptions)
await next()
}
}
Expand Down
6 changes: 3 additions & 3 deletions api/test/ipfs-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ipfsAPI = require('ipfs-api')
const ipfsApiOptions = '127.0.0.1'
const ipfsClient = require('ipfs-http-client')
const ipfsClientOptions = '127.0.0.1'

const ipfs = ipfsAPI(ipfsApiOptions)
const ipfs = ipfsClient(ipfsClientOptions)
const { randomBytes } = require('crypto')

const generateHash = async () => {
Expand Down
Loading

0 comments on commit 00d061d

Please sign in to comment.