3
3
const fs = require ( 'fs' )
4
4
const os = require ( 'os' )
5
5
const path = require ( 'path' )
6
- // const IPFS = require('../../src/core')
6
+ const IPFS = require ( '../../src/core' )
7
7
// replace this by line below if you are using ipfs as a dependency of your
8
8
// project
9
- const IPFS = require ( 'ipfs' )
9
+ // const IPFS = require('ipfs')
10
10
11
11
/*
12
12
* Create a new IPFS instance, using default repo (fs) on default path (~/.ipfs)
13
13
*/
14
14
const node = new IPFS ( {
15
15
repo : path . join ( os . tmpdir ( ) + '/' + new Date ( ) . toString ( ) ) ,
16
16
init : false ,
17
- start : false ,
18
- EXPERIMENTAL : {
19
- pubsub : false
20
- }
17
+ start : false
21
18
} )
22
19
23
20
const fileToAdd = {
@@ -37,16 +34,12 @@ node.version()
37
34
/*
38
35
* Initialize the repo for this node
39
36
*/
40
- . then ( ( ) => {
41
- return node . init ( { emptyRepo : true , bits : 2048 } )
42
- } )
37
+ . then ( ( ) => node . init ( { emptyRepo : true , bits : 2048 } ) )
43
38
44
39
/*
45
40
* Take the node online (bitswap, network and so on)
46
41
*/
47
- . then ( ( ) => {
48
- return node . start ( )
49
- } )
42
+ . then ( ( ) => node . start ( ) )
50
43
51
44
/*
52
45
* Add a file to IPFS - Complete Files API on:
@@ -71,9 +64,7 @@ node.version()
71
64
* Awesome we've added a file so let's retrieve and
72
65
* display its contents from IPFS
73
66
*/
74
- . then ( ( fileMultihash ) => {
75
- return node . files . cat ( fileMultihash )
76
- } )
67
+ . then ( ( fileMultihash ) => node . files . cat ( fileMultihash ) )
77
68
78
69
. then ( ( stream ) => {
79
70
console . log ( '\nFile content:' )
@@ -82,10 +73,6 @@ node.version()
82
73
return Promise . resolve ( )
83
74
} )
84
75
85
- . then ( ( ) => {
86
- console . log ( 'Success!' )
87
- } )
76
+ . then ( ( ) => console . log ( 'Success!' ) )
88
77
89
- . catch ( ( err ) => {
90
- console . log ( err )
91
- } )
78
+ . catch ( ( err ) => console . log ( err ) )
0 commit comments