go-ipfs-wrapper
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

go-ipfs-wrapper

This helps to execute go-ipfs in javascript.

Install

This is available through npm.

npm install go-ipfs-wrapper --save

Usage

To execute go-ipfs,

import { IpfsProcess } from 'go-ipfs-wrapper';
 
const ipfs = new IpfsProcess('./.ipfs');
 
ipfs.on('start', () => console.log('go-ipfs is started!'));
ipfs.on('error', (err) => console.error(err));
ipfs.on('exit', (code) => console.log(`exit go-ipfs with code ${code}`))
 
ipfs.run();

To interact with go-ipfs, use js-ipfs-api. Even you already use js-ipfs module, you can easily change to go-ipfs since the interface for interacting with go-ipfs or js-ipfs in javascript is the same.

import { IpfsProcess } from 'go-ipfs-wrapper';
import * as IpfsAPI from 'ipfs-api';
 
const ipfs = new IpfsProcess('./ipfs');
 
ipfs.on('start', () => {
  // ipfs-api should be used after start event emitted
  const api = IpfsAPI('localhost', '5001', {protocol: 'http'});
  
  // push test file to the IPFS network.
  // (same interface with js-ipfs using ipfs-api module)
  api.files.add({
    path: '/test.txt',
    content: 'hello, world!'
  });
});

License

MIT

Package Sidebar

Install

npm i go-ipfs-wrapper

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

148 MB

Total Files

11

Last publish

Collaborators

  • ksw3894