Skip to content

Commit 52f1530

Browse files
author
Victor Bjelkholm
committed
Get IPFS to work
1 parent 306733d commit 52f1530

File tree

4 files changed

+45
-43
lines changed

4 files changed

+45
-43
lines changed

README.md

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,14 @@
1-
react-hot-boilerplate
1+
ipfs-webpack demo
22
=====================
33

4-
The minimal dev environment to enable live-editing React components.
4+
Quick demo on how to use node-ipfs-api together with webpack.
55

6-
### Usage
6+
I had some issues getting it to work so this is just a sample demo.
77

8-
```
9-
npm install
10-
npm start
11-
open http://localhost:3000
12-
```
8+
[commit]
139

14-
Now edit `src/App.js`.
15-
Your changes will appear without reloading the browser like in [this video](http://vimeo.com/100010922).
10+
### To run
1611

17-
### Linting
12+
Start the deamon with `API_ORIGIN="*" ipfs daemon`
1813

19-
This boilerplate project includes React-friendly ESLint configuration.
20-
21-
```
22-
npm run lint
23-
```
24-
25-
### Using `0.0.0.0` as Host
26-
27-
You may want to change the host in `server.js` and `webpack.config.js` from `localhost` to `0.0.0.0` to allow access from same WiFi network. This is not enabled by default because it is reported to cause problems on Windows. This may also be useful if you're using a VM.
28-
29-
### Missing Features
30-
31-
This boilerplate is purposefully simple to show the minimal configuration for React Hot Loader. For a real project, you'll want to add a separate config for production with hot reloading disabled and minification enabled. You'll also want to add a router, styles and maybe combine dev server with an existing server. This is out of scope of this boilerplate, but you may want to look into [other starter kits](https://github.com/gaearon/react-hot-loader/blob/master/docs/README.md#starter-kits).
32-
33-
### Dependencies
34-
35-
* React
36-
* Webpack
37-
* [webpack-dev-server](https://github.com/webpack/webpack-dev-server)
38-
* [babel-loader](https://github.com/babel/babel-loader)
39-
* [react-hot-loader](https://github.com/gaearon/react-hot-loader)
40-
41-
### Resources
42-
43-
* [Demo video](http://vimeo.com/100010922)
44-
* [react-hot-loader on Github](https://github.com/gaearon/react-hot-loader)
45-
* [Integrating JSX live reload into your workflow](http://gaearon.github.io/react-hot-loader/getstarted/)
46-
* [Troubleshooting guide](https://github.com/gaearon/react-hot-loader/blob/master/docs/Troubleshooting.md)
47-
* Ping dan_abramov on Twitter or #reactjs IRC
14+
Run `npm install` and then `npm run` and the application should be running on `http://localhost:3000`

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"webpack-dev-server": "^1.8.2"
3838
},
3939
"dependencies": {
40+
"ipfs-api": "^2.4.1",
41+
"json-loader": "^0.5.3",
4042
"react": "^0.13.0"
4143
}
4244
}

src/App.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
import React, { Component } from 'react';
22

3+
import ipfsAPI from 'ipfs-api'
4+
5+
var ipfs = ipfsAPI('localhost', '5001')
6+
37
export default class App extends Component {
8+
constructor(props) {
9+
super(props)
10+
this.state = {
11+
id: null,
12+
version: null,
13+
protocol_version: null
14+
}
15+
}
16+
componentDidMount() {
17+
ipfs.id((err, res) => {
18+
if(err) {
19+
console.error(err)
20+
return
21+
}
22+
this.setState({
23+
id: res.ID,
24+
version: res.AgentVersion,
25+
protocol_version: res.ProtocolVersion
26+
})
27+
})
28+
}
429
render() {
530
return (
6-
<h1>Hello, world.</h1>
31+
<div style={{textAlign: 'center'}}>
32+
<h1>Everything is working!</h1>
33+
<p>Your ID is <strong>{this.state.id}</strong></p>
34+
<p>Your IPFS version is <strong>{this.state.version}</strong></p>
35+
<p>Your IPFS protocol version is <strong>{this.state.protocol_version}</strong></p>
36+
</div>
737
);
838
}
939
}

webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ module.exports = {
2121
test: /\.js$/,
2222
loaders: ['react-hot', 'babel'],
2323
include: path.join(__dirname, 'src')
24-
}]
25-
}
24+
},{ test: /\.json$/, loader: "json-loader" }]
25+
},
26+
node: {
27+
fs: 'empty'
28+
}
2629
};

0 commit comments

Comments
 (0)