Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okdistribute/hypercore-stats-server
send hypercore/hyperdrive stats over server-side events
https://github.com/okdistribute/hypercore-stats-server
Last synced: 19 days ago
JSON representation
send hypercore/hyperdrive stats over server-side events
- Host: GitHub
- URL: https://github.com/okdistribute/hypercore-stats-server
- Owner: okdistribute
- Created: 2016-07-09T00:56:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-10T07:41:33.000Z (almost 7 years ago)
- Last Synced: 2024-05-16T13:19:02.865Z (9 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 10
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dat - hyperdrive-stats-server - server for sending hypercore / hyperdrive stats over server-side events (Outdated / Other Related Dat Project Modules)
README
# hypercore-stats-server
Server for sending hypercore/hyperdrive stats over server-side events.
```
npm install hypercore-stats-server
```### Example
````
var hyperdiscovery = require('hyperdiscovery')
var hyperdrive = require('hyperdrive')
var http = require('http')
var ram = require('random-access-memory')
var stats = require('hypercore-stats-server')// create a server
http.createServer(function (req, res) {// set up a drive
var drive = hyperdrive(ram, '72671c5004d3b956791b6ffca7f05025d62309feaf99cde04c6f434189694291')
hyperdiscovery(archive)// stats for the given drive will be sent to /events
if (req.url === '/events') stats(archive, res)
else res.end('hi. hit /events for stat events')
}).listen(10000)
```### API
##### `stats(archive, response)`
Takes a hyperdrive archive and an `http` response object. Will return server side events to the response object that represent stats as they are downloaded through the swarm.