GithubHelp home page GithubHelp logo

isabella232 / js-dag-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ipfs/js-dag-service

0.0 0.0 0.0 1.95 MB

Library for storing and replicating hash-linked data over the IPFS network.

License: Other

JavaScript 0.76% TypeScript 99.24%

js-dag-service's Introduction

DAGService

Chat on IRC Chat on Matrix GitHub package.json version npm (scoped) Release docs standard-readme compliant

DAGService is a library for storing and replicating hash-linked data over the IPFS network.

DAGService is aiming to be a bare minimum needed for IPLD-based applications to interact with the IPFS network by getting and putting blocks to it.

NOTE For now, this is a highly experimental library. Use with caution.

This project was originally developed under the @textileio organization, and was contributed to the IPFS community for ongoing maintenance and development.

Table of Contents

Background

The goal of DAGService to provied a minimal layer between data model of IPLD and full blown IPFS. It provides bare minimum functionality for any application to interact with the IPFS network (by getting and putting IPLD blocks) without having to deal with the complexities of operating a full IPFS node. It is an attempt to remake core piece of IPFS node reusable on it's own.

Why?

Because 99% of the time, a browser or mobile (d)App only needs to be able to add and get small bits of data over the IPFS network. This library provides that, in a much smaller package (currently less than 1/2 the size of js-ipfs without much optimization -- we will continue to optimize further). It is also highly extensible, so developers need only include the features they need, keeping load times fast, and (d)Apps feeling snappy. Additionally, Textile needed a Typescript-based IPFS solution, and we think others will find the type safety useful as well. Feel free to use the Typescript declarations in your own projects.

Install

npm install dag-service

Usage

import { Peer, BlockStore } from "dag-service"
// Use any interface-datastore compliant store
import { MemoryDatastore } from "interface-datastore"
import Libp2p from "libp2p"

const store = new BlockStore(new MemoryDatastore())

const main = async () => {
  // Bring your own libp2p host....
  const host = new Libp2p({ ...libp2Options })
  const lite = new Peer(store, host)

  await lite.start()

  const cid = "QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u"
  const data = await lite.getFile(cid)
  console.log(data.toString())
  // Hello World
  await lite.stop()
}

There are also several useful examples included in the tests of this repo, with tools for creating a default libp2p host exported by default. We've also thrown in some useful interfaces to use when building on IPFS Lite, as well as the Buffer API for use in the browser.

API

See https://ipfs.github.io/js-dag-service/

Maintainers

Contribute

Feel free to dive in! Open an issue or submit PRs.

To contribute to IPFS in general, see the contributing guide.

Project follows the IPFS Community Code of Conduct

License

The js-dag-service project is dual-licensed under Apache 2.0 and MIT terms:

js-dag-service's People

Contributors

andrewxhill avatar carsonfarmer avatar dependabot-preview[bot] avatar gozala avatar mithray avatar pcowgill avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.