Created
December 3, 2019 14:29
-
-
Save dpaez/f85feaddf9533228c033abbe50ef61ac to your computer and use it in GitHub Desktop.
p2pcommons: sdk-js: content creation and seeding small example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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