Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyperdrive-http

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperdrive-http

Handle Hyperdrive HTTP Requests

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
decreased by-55.29%
Maintainers
1
Weekly downloads
 
Created
Source

Hyperdrive Http

Handle Hyperdrive HTTP Requests

Expects you to:

  • Bring your own http server
  • Manage your own hyperdrive archives
  • Connect to the swarm before callback

Usage

Initiate with an archive lookup function: var onrequest = hyperdriveHttp(getArchive)

or pass a single archive: var onrequest = hyperdriveHttp(archive)

var hyperdriveHttp = require('hyperdrive-http')

var getArchive = function (datInfo, cb) {
  // find the archive to serve
  var archive = cache.get(datInfo.discoveryKey)
  if (!archive) {
    archive = drive.createArchive(datInfo.key)
    // connect to swarm, if necessary
    sw.join(archive.discoveryKey)
  }
  cb(null, archive) // callback with your found archive
}

var onrequest = hyperdriveHttp(getArchive)
var server = http.createServer()
server.listen(8000)
server.on('request', onrequest)

Pass an archive lookup function for the first argument of hyperdriveHttp. The function is called with datInfo and a callback.

datInfo = {
  key: archive.key,
  discoveryKey: archive.discoveryKey,
  filename: someFile.txt,
}

FAQs

Package last updated on 30 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc