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

Commit

Permalink
fix: change default values of js-ipfs to avoid clash with go-ipfs + c…
Browse files Browse the repository at this point in the history
…lean the browserify example
  • Loading branch information
daviddias committed Dec 10, 2016
1 parent 4252559 commit 6d52e1c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 30 deletions.
20 changes: 2 additions & 18 deletions examples/bundle-webpack/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# Bundle js-ipfs-api with Webpack!
# Bundle js-ipfswith Webpack!

> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs-api with webpack, so that you can use it in your own web app!
## Setup

As for any js-ipfs-api example, **you need a running IPFS daemon**, you learn how to do that here:

- [Spawn a go-ipfs daemon](https://ipfs.io/docs/getting-started/)
- [Spawn a js-ipfs daemon](https://github.com/ipfs/js-ipfs#usage)

**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-api#cors to learn how to do that.

A quick (and dirty way to get it done) is:

```bash
> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"
> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
```
> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs with webpack, so that you can use it in your own web app!
## Run this example

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
console.log('Initializing daemon...')
httpAPI = new HttpAPI(process.env.IPFS_PATH)
httpAPI.start((err) => {
if (err.code === 'ENOENT') {
if (err && err.code === 'ENOENT') {
console.log('Error: no ipfs repo found in ' + process.env.IPFS_PATH)
console.log('please run: jsipfs init')
process.exit(1)
Expand Down
5 changes: 4 additions & 1 deletion src/cli/commands/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ module.exports = {
builder: {},

handler (argv) {
const path = argv['ipfs-path']
let path = argv['ipfs-path']
if (path.indexOf('/ipfs/') !== 1) {
path = path.replace('/ipfs/', '')
}

waterfall([
(cb) => utils.getIPFS(cb),
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exports.getIPFS = (callback) => {
}

exports.getRepoPath = () => {
return process.env.IPFS_PATH || os.homedir() + '/.ipfs'
return process.env.IPFS_PATH || os.homedir() + '/.jsipfs'
}

exports.createLogger = (visible) => {
Expand Down
8 changes: 5 additions & 3 deletions src/core/components/init-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const glob = require('glob')
const importer = require('ipfs-unixfs-engine').importer
const pull = require('pull-stream')
const file = require('pull-file')
const mh = require('multihashes')
// const mh = require('multihashes')

// Add the default assets to the repo.
module.exports = function addDefaultAssets (self, log, callback) {
Expand Down Expand Up @@ -35,10 +35,12 @@ module.exports = function addDefaultAssets (self, log, callback) {
importer(self._ipldResolver),
pull.through((el) => {
if (el.path === 'files/init-docs/docs') {
const hash = mh.toB58String(el.multihash)
// const hash = mh.toB58String(el.multihash)
log('to get started, enter:')
log()
log(`\t jsipfs files cat /ipfs/${hash}/readme`)
log(`\t jsipfs files cat /ipfs/QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB`)
// TODO when we support pathing in unixfs-engine
// log(`\t jsipfs files cat /ipfs/${hash}/readme`)
log()
}
}),
Expand Down
4 changes: 3 additions & 1 deletion src/core/default-repo-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ const IPFSRepo = require('ipfs-repo')

module.exports = (dir) => {
const repoPath = dir || 'ipfs'
return new IPFSRepo(repoPath, {stores: Store})
return new IPFSRepo(repoPath, {
stores: Store
})
}
7 changes: 5 additions & 2 deletions src/core/default-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const IPFSRepo = require('ipfs-repo')
const path = require('path')

module.exports = (dir) => {
const repoPath = dir || path.join(os.homedir(), '.ipfs')
return new IPFSRepo(repoPath, {stores: Store})
const repoPath = dir || path.join(os.homedir(), '.jsipfs')

return new IPFSRepo(repoPath, {
stores: Store
})
}
6 changes: 3 additions & 3 deletions src/init-files/default-config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"Addresses": {
"Swarm": [
"/ip4/0.0.0.0/tcp/4001"
"/ip4/0.0.0.0/tcp/4002"
],
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080"
"API": "/ip4/127.0.0.1/tcp/5002",
"Gateway": "/ip4/127.0.0.1/tcp/9090"
},
"Discovery": {
"MDNS": {
Expand Down

0 comments on commit 6d52e1c

Please sign in to comment.