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 - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

27

index.js

@@ -1,2 +0,1 @@

var http = require('http')
var crypto = require('crypto')

@@ -10,15 +9,6 @@ var pump = require('pump')

var PORT = process.env.PORT || 8080
module.exports = HyperdriveHttp
function HyperdriveHttp (getArchive, opts) {
if (!opts) opts = {}
opts.port = opts.port || PORT
var server = this.server = http.createServer()
server.listen(opts.port, function () {
console.log('Server is listening on port ' + opts.port)
})
server.on('request', function (req, res) {
function HyperdriveHttp (getArchive) {
var onrequest = function (req, res) {
var dat = parse(req.url)

@@ -30,11 +20,10 @@ if (!dat) return onerror(404, res)

})
})
return server
}
return onrequest
}
function archiveResponse (archive, req, res) {
if (!archive) {
console.error('no archive')
process.exit(0)
}
if (!archive) onerror(404, res)
var dat = parse(req.url)

@@ -94,2 +83,2 @@

}
}
}
{
"name": "hyperdrive-http",
"version": "1.0.0",
"description": "serve a hyperdrive over http",
"version": "2.0.0",
"description": "Handle Hyperdrive HTTP Requests",
"main": "index.js",
"scripts": {
"test": "standard && tape test/*.js | tap-spec"
"test": "standard && echo 'Error: no test specified'"
},

@@ -18,3 +18,11 @@ "author": "Joe Hand <joe@joeahand.com> (http://joeahand.com/)",

"through-timeout": "^1.0.0"
}
},
"repository": {
"type": "git",
"url": "https://github.com/joehand/hyperdrive-http.git"
},
"bugs": {
"url": "https://github.comm/joehand/hyperdrive-http/issues"
},
"homepage": "https://github.com/joehand/hyperdrive-http"
}
# Hyperdrive Http
Serve a Hyperdrive over 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
```
```javascript
var hyperdriveHttp = require('hyperdrive-http')
var opts = {port: 8000}
var getArchive = function (datInfo, cb) {
var archive = cache.get(dat.discoveryKey)
// find the archive to serve
var archive = cache.get(datInfo.discoveryKey)
if (!archive) {
archive = drive.createArchive(dat.key, {file: file})
archive = drive.createArchive(datInfo.key)
// connect to swarm, if necessary
sw.join(archive.discoveryKey)
}
cb(null, archive) // callback with your archive
cb(null, archive) // callback with your found archive
}
var server = hyperdriveHttp(getArchive, opts)
var onrequest = hyperdriveHttp(getArchive)
var server = http.createServer()
server.listen(8000)
server.on('request', onrequest)
```

@@ -25,3 +34,3 @@

```
```javascript
datInfo = {

@@ -28,0 +37,0 @@ key: archive.key,

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