Skip to content

Control an ipfs node daemon using Node.js

License

Notifications You must be signed in to change notification settings

JGAntunes/js-ipfsd-ctl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipfsd-ctl

standard-readme compliant Coverage Status Travis CI Circle CI Dependency Status js-standard-style

Control an ipfs node daemon using Node.js

Table of Contents

Install

Install:

npm install --save ipfsd-ctl

The current go ipfs version used is v0.4.3-rc3

Usage

IPFS daemons are already easy to start and stop, but this module is here to do it from javascript itself.

// start a disposable node, and get access to the api
// print the node id, and kill the temporary daemon

// IPFS_PATH will point to /tmp/ipfs_***** and will be
// cleaned up when the process exits.

const ipfsd = require('ipfsd-ctl')

ipfsd.create((err, node) => {
  if (err) throw err
  node.startDaemon((err) => {
    if (err) throw err
    const ipfs = node.apiCtl()
    ipfs.id((err, id) => {
      console.log(id)
      process.kill()
    })
  })
})

The daemon controller safely spawns the node for you and exposes you an ipfs API client through node.apiCtl(). If the parent process exits, the daemon will also be killed ensuring that the daemon isn't left hanging.

This module works by downloading the binary once, on first use, if it detects that no current binary is available to use. So keep in mind that the first command executed might throw in some overhead.

If you want to use an existing ipfs installation you can set $IPFS_EXEC=/path/to/ipfs to ensure it uses that.

API

ipfsd

ipfsd.local(path, done)

ipfsd.create(opts, done)

IPFSNode(path, opts, disposable)

node.init(initOpts, done)

node.shutdown(done)

node.startDaemon(done)

node.stopDaemon(done)

node.apiCtl(done)

node.daemonPid()

node.getConfig(key, done)

node.setConfig(key, value, done)

node.replaceConf(file, done)

node.version(done)

node.subprocess

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT

About

Control an ipfs node daemon using Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%