Skip to content

Instantly share code, notes, and snippets.

@dpaez
Created December 3, 2019 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpaez/f85feaddf9533228c033abbe50ef61ac to your computer and use it in GitHub Desktop.
Save dpaez/f85feaddf9533228c033abbe50ef61ac to your computer and use it in GitHub Desktop.
p2pcommons: sdk-js: content creation and seeding small example
const P2PCommons = require('.') // liberate science constructor function
const tempy = require('tempy')
const commons = new P2PCommons({ baseDir: tempy.directory(), verbose: true })
process.once('SIGINT', () => commons.destroy())
;(async () => {
await commons.ready()
// create some content
const { rawJSON, metadata } = await commons.init({
type: 'content',
title: 'Cool 101',
description: 'All the cool content you want to know'
})
console.log({ metadata })
console.log({ rawJSON })
console.log('P2PCommons swarming listening...')
commons.destroy(true, false)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment