You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+86-32Lines changed: 86 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,8 @@ We've come a long way, but this project is still in Alpha, lots of development i
90
90
-[Network](#network)
91
91
-[Node Management](#node-management)
92
92
-[Static types and utils](#static-types-and-utils)
93
+
-[Glob source](#glob-source)
94
+
-[URL source](#url-source)
93
95
-[FAQ](#faq)
94
96
-[How to enable WebRTC support for js-ipfs in the Browser](#how-to-enable-webrtc-support-for-js-ipfs-in-the-browser)
95
97
-[Is there WebRTC support for js-ipfs with Node.js?](#is-there-webrtc-support-for-js-ipfs-with-nodejs)
@@ -300,9 +302,9 @@ a case, you should provide a way to trigger migrations manually.**
300
302
|------|---------|
301
303
| boolean or object |`true`|
302
304
303
-
Initialize the repo when creating the IPFS node.
305
+
Perform repo initialization steps when creating the IPFS node.
304
306
305
-
If you have already initialized a repo before creating your IPFS node (e.g. you are loading a repo that was saved to disk from a previous run of your program), you must make sure to set this to `false`. Note that *initializing* a repo is different from creating an instance of [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo). The IPFS constructor sets many special properties when initializing a repo, so you should usually not try and call `repoInstance.init()` yourself.
307
+
Note that *initializing* a repo is different from creating an instance of [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo). The IPFS constructor sets many special properties when initializing a repo, so you should usually not try and call `repoInstance.init()` yourself.
306
308
307
309
Instead of a boolean, you may provide an object with custom initialization options. All properties are optional:
308
310
@@ -312,13 +314,13 @@ Instead of a boolean, you may provide an object with custom initialization optio
312
314
```js
313
315
// Generating a Peer ID:
314
316
constPeerId=require('peer-id')
315
-
PeerId.create({ bits:2048 }, (err, peerId) => {
316
-
// Generates a new Peer ID, complete with public/private keypair
317
-
// See https://github.com/libp2p/js-peer-id
318
-
})
317
+
// Generates a new Peer ID, complete with public/private keypair
318
+
// See https://github.com/libp2p/js-peer-id
319
+
constpeerId=awaitPeerId.create({ bits:2048 })
319
320
```
320
321
-`pass` (string) A passphrase to encrypt keys. You should generally use the [top-level `pass` option](#optionspass) instead of the `init.pass`option (this one will take its value from the top-level option if not set).
321
322
-`profiles` (Array) Apply profile settings to config.
323
+
-`allowNew` (boolean, default:`true`) Set to `false` to disallow initialization if the repo does not already exist.
322
324
323
325
##### `options.start`
324
326
@@ -407,6 +409,11 @@ Available delegate multiaddrs are:
407
409
408
410
**Note**: If more than 1 delegate multiaddr is specified, the actual delegate will be randomly selected on startup.
409
411
412
+
**Note**: If you wish to use delegated routing and are creating your node _programmatically_ in Node.js or the browser you must `npm install libp2p-delegated-content-routing` and/or `npm install libp2p-delegated-peer-routing` and provide configured instances of them in [`options.libp2p`](#optionslibp2p). See the module repos for further instructions:
@@ -548,10 +555,12 @@ The libp2p option allows you to build your libp2p node by configuration, or via
548
555
You can see the bundle in action in the [custom libp2p example](examples/custom-libp2p).
549
556
550
557
- `modules` (object):
551
-
- `transport` (Array<[libp2p.Transport](https://github.com/libp2p/interface-transport)>): An array of Libp2p transport classes/instances to use _instead_ of the defaults. See [libp2p/interface-transport](https://github.com/libp2p/interface-transport) for details.
552
-
- `peerDiscovery` (Array<[libp2p.PeerDiscovery](https://github.com/libp2p/interface-peer-discovery)>): An array of Libp2p peer discovery classes/instances to use _instead_ of the defaults. See [libp2p/peer-discovery](https://github.com/libp2p/interface-peer-discovery) for details. If passing a class, configuration can be passed using the config section below under the key corresponding to you module's unique `tag` (a static property on the class)
558
+
- `transport` (Array<[libp2p.Transport](https://github.com/libp2p/js-interfaces/tree/master/src/transport)>): An array of Libp2p transport classes/instances to use _instead_ of the defaults. See [libp2p/js-interfaces/transport](https://github.com/libp2p/js-interfaces/tree/master/src/transport) for details.
559
+
- `peerDiscovery` (Array<[libp2p.PeerDiscovery](https://github.com/libp2p/js-interfaces/tree/master/src/peer-discovery)>): An array of Libp2p peer discovery classes/instances to use _instead_ of the defaults. See [libp2p/js-interfaces/peer-discovery](https://github.com/libp2p/js-interfaces/tree/master/src/peer-discovery) for details. If passing a class, configuration can be passed using the config section below under the key corresponding to you module's unique `tag` (a static property on the class)
553
560
- `dht` (object): a DHT implementation that enables PeerRouting and ContentRouting. Example [libp2p/js-libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
554
561
- `pubsub` (object): a Pubsub implementation on top of [libp2p/js-libp2p-pubsub](https://github.com/libp2p/js-libp2p-pubsub)
562
+
- `contentRouting` (Array<[libp2p.ContentRouting](https://github.com/libp2p/js-interfaces/tree/master/src/content-routing)>): An array of Libp2p content routing modules. See [libp2p/js-interfaces/content-routing](https://github.com/libp2p/js-interfaces/tree/master/src/content-routing) for details.
563
+
- `peerRouting` (Array<[libp2p.PeerRouting](https://github.com/libp2p/js-interfaces/tree/master/src/peer-routing)>): An array of Libp2p peer routing modules. See [libp2p/js-interfaces/peer-routing](https://github.com/libp2p/js-interfaces/tree/master/src/peer-routing) for details.
555
564
- `config` (object):
556
565
- `peerDiscovery` (object):
557
566
- `autoDial` (boolean): Dial to discovered peers when under the Connection Manager min peer count watermark. (default `true`)
The IPFS core API provides all functionality that is not specific to setting up and starting or stopping a node. This API is available directly on an IPFS instance, on the command line (when using the CLI interface), and as an HTTP REST API. For a complete reference, see [](https://github.com/ipfs/interface-ipfs-core).
739
748
740
-
All the API methods aside from streaming methods (ones that end in `ReadableStream` or `PullStream`) are asynchronous and return Promises, but _also_ accept callbacks.
A utility to allow files on the file system to be easily added to IPFS.
922
+
923
+
###### `globSource(path, [options])`
924
+
925
+
- `path`: A path to a single file or directory to glob from
926
+
- `options`: Optional options
927
+
- `options.recursive`: If `path` is a directory, use option `{ recursive:true }` to add the directory and all its sub-directories.
928
+
- `options.ignore`: To exclude file globs from the directory, use option `{ ignore: ['ignore/this/folder/**', 'and/this/file'] }`.
929
+
- `options.hidden`: Hidden/dot files (files or folders starting with a `.`, for example, `.git/`) are not included by default. To add them, use the option `{ hidden:true }`.
930
+
931
+
Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
0 commit comments