https://github.com/synonymdev/slashtags-widget-facts-feed
https://github.com/synonymdev/slashtags-widget-facts-feed
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/synonymdev/slashtags-widget-facts-feed
- Owner: synonymdev
- License: mit
- Archived: true
- Created: 2022-11-15T00:42:48.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T11:47:54.000Z (almost 2 years ago)
- Last Synced: 2025-05-18T13:02:03.327Z (11 months ago)
- Language: JavaScript
- Size: 82 KB
- Stars: 0
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slashtags-widget-facts-feed
A slashtags widget with interesting facts about Bitcoin.
## Usage
### Feed
Copy `config/config.example.json` to `config/config.json` then edit the relay address.
```bash
cp config/config.example.json config/config.json
```
In `config/config.json` you should edit the `facts` array to include all the facts you need to publish.
Start the feed writer
```bash
npm start
```
It will generate a `keyPair` and persist that in `config/config.json` for future sessions.
It should print: `Running Bitcoin facts feed: slashfeed:/Bitcoin Facts?relay=`
### Reader
To read The facts feed use the `Reader` helper class.
```js
const { Feed, Reader } = require('slashtags-widget-facts-feed');
(async () => {
const client = new Client({ storage: './path/to/feed/storage', relay: 'https://web-relay.example.com' })
const feed = new Feed(client, config, { icon })
await feed.ready()
await feed.writeFacts(['fact 1', 'fact 2', 'fact 3'])
const client = new Client({ storage: './path/to/reader/storage'})
const readerClient = new Client({ storage: tmpdir() })
const reader = new Reader(readerClient, feed.url)
const facts = await reader.getAllFacts()
const random = await reader.getRandomFact()
})
```