orbit-satellite

0.1.4 • Public • Published

Satellite

OrbitDB based library for building operations based OrbitDB Apps and making all unnecessary complexity optional.

This library automatically sets up IPFS and OrbitDB to be deployable in the Browser & on NodeJS.

Install

npm i --save orbit-satellite

Usage

const Satellite = require("orbit-satellite")

const inc = {
  name: "inc",
  apply(state, entry = { value: 1 }) {
    state.value += entry.value
    return state
  },
}

Satellite.addStore({
    type: "counter",
    operations: [inc],
    initialState: { value: 0 },
})

async function main() {
  const satellite = await Satellite.createInstance()

  const db = await satellite.create("someValues", "counter")

  await db.inc()

  console.log(db.state.value)
}

See examples

Browsers

To change the IPFS and OrbitDB configuration, change the Satellite.ipfsConfig and Satellite.orbitdbConfig.

These are configured already for use in the Browser. To use it in the browser, add the stores, export Satellite and browserify the module.

module.exports = Satellite

Package Sidebar

Install

npm i orbit-satellite

Weekly Downloads

2

Version

0.1.4

License

AGPL-3.0-or-later

Unpacked Size

45.3 kB

Total Files

7

Last publish

Collaborators

  • csdummi