dPay

dweb.json Metadata

Background

Read and Write dpack.json Files

Install

Install With NPM

npm install dpack-meta

Install With YARN

yarn add dpack-meta

Usage

var dPackMeta = require('dpack-meta')

var dpackjson = dPackMeta(vault)

dpackjson.create({title: 'a dPack', description: 'this is my dPack description'}, function (err) {
  if (err) throw err
})

dpackjson.read(function (err, data) {
  console.log(data)
})

Write to a dpack.json on the file system also:

var dPackMeta = require('dpack-meta')

var dpackjson = dPackMeta(vault, {file: path.join(dpack.path, 'dpack.json')})

dpackjson.create({title: 'dPack title', description: 'This is my awesome dSite.'}, function (err) {
  if (err) throw err
})

API

var dpackjson = dPackMeta(vault, [opts])

creates a new dpackMeta db

Options:

  • opts.file - dpack.json file path, updates will be written to file system and vault

dpackjson.create([data], cb)

Create a new dpack.json file in the vault with the default keys (url, title, description). Pass in any additional data to add on initial create.

dpackjson.write(key, val, cb) or dpackjson.write(data, cb)

Write a single key and value or an object, data, to the dpack.json file. Use file option above to also update the file on the file system.

dpackjson.delete(key, cb)

Delete a key from the dpack.json file.

dpackjson.read(cb)

Read the current dpack.json.