Skip to content

justinmchase/js-ipfs-repo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPFS Repo JavaScript Implementation

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

Sauce Test Status

Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript

This is the implementation of the IPFS repo spec in JavaScript.

Table of Contents

Background

Here is the architectural reasoning for this repo:

                          ┌────────────────────────────────────────┐
                          │                IPFSRepo                │
                          └────────────────────────────────────────┘
                                      ┌─────────────────┐
                                      │        /        │
                                      ├─────────────────┤
                                      │    Datastore    │
                                      └─────────────────┘
                                               │
                                   ┌───────────┴───────────┐
                                   │                       │
                          ┌─────────────────┐     ┌─────────────────┐
                          │     /blocks     │     │   /datastore    │
                          ├─────────────────┤     ├─────────────────┤
                          │    Datastore    │     │ LevelDatastore  │
                          └─────────────────┘     └─────────────────┘

┌────────────────────────────────────────┐          ┌────────────────────────────────────────┐
│       IPFSRepo - Default Node.js       │          │       IPFSRepo - Default Browser       │
└────────────────────────────────────────┘          └────────────────────────────────────────┘
            ┌─────────────────┐                                 ┌─────────────────┐
            │        /        │                                 │        /        │
            ├─────────────────┤                                 ├─────────────────┤
            │   FsDatastore   │                                 │LevelJSDatastore │
            └─────────────────┘                                 └─────────────────┘
                     │                                                   │
         ┌───────────┴───────────┐                           ┌───────────┴───────────┐
         │                       │                           │                       │
┌─────────────────┐     ┌─────────────────┐         ┌─────────────────┐     ┌─────────────────┐
│     /blocks     │     │   /datastore    │         │     /blocks     │     │   /datastore    │
├─────────────────┤     ├─────────────────┤         ├─────────────────┤     ├─────────────────┤
│ FlatfsDatastore │     │LevelDBDatastore │         │LevelJSDatastore │     │LevelJSDatastore │
└─────────────────┘     └─────────────────┘         └─────────────────┘     └─────────────────┘

This provides a well defined interface for creating and interacting with an IPFS repo.

Install

npm

> npm install ipfs-repo

Use in Node.js

var IPFSRepo = require('ipfs-repo')

Use in a browser with browserify, webpack or any other bundler

var IPFSRepo = require('ipfs-repo')

Use in a browser Using a script tag

Loading this module through a script tag will make the IpfsRepo obj available in the global namespace.

<script src="https://unpkg.com/ipfs-repo/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipfs-repo/dist/index.js"></script>

Usage

Example:

const Repo = require('ipfs-repo')
const repo = new Repo('/tmp/ipfs-repo')

repo.init({ cool: 'config' }, (err) => {
  if (err) {
    throw err
  }

  repo.open((err) => {
    if (err) {
      throw err
    }

    console.log('repo is ready')
  })
})

This now has created the following structure, either on disk or as an in memory representation:

├── blocks
│   ├── SHARDING
│   └── _README
├── config
├── datastore
└── version

API

See https://ipfs.github.io/js-ipfs-repo

Notes

Contribute

There are some ways you can make this module better:

  • Consult our open issues and take on one of them
  • Help our tests reach 100% coverage!

This repository falls under the IPFS Code of Conduct.

License

MIT

About

Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%