Code Monkey home page Code Monkey logo

hyperdrive-http's Introduction

deprecated

More info on active projects and modules at dat-ecosystem.org


Hyperdrive Http

Serve a hyperdrive archive over HTTP. For an example of use, see dat.haus.

Travis

Usage

Hyperdrive-http returns a function to call when you receive a http request:

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

Supports manifest options in dat.json:

  • web_root - change directory to serve on index
  • fallback_page - fallback for 404 errors

Setup

To use hyperdrive-http you will need to:

  • Create your own http server
  • Setup your hyperdrive archive
  • For remote archives, connect to the swarm

API

Hyperdrive works with many archives/feeds or a single archive.

Options

  • exposeHeaders - If set to true, hyperdrive-http will add custom Hyperdrive- HTTP headers to directory listing requests (default: false):
    Hyperdrive-Key: de2a51bbaf8a5545eff82c999f15e1fd29637b3f16db94633cb6e2e0c324f833
    Hyperdrive-Version: 4
  • live - If set to true will reload a directly listing if the archive receives updates.
  • footer - Add a footer to your HTML page. Automatically adds archive version number to footer.

URL Format

Hyperdrive-http responds to any URL with a specific format. If the URL does cannot be parsed, it will return a 404.

  • Get archive listing: http://archive-example.com/
  • Get file from archive: http://archive-example.com/filename.pdf

If a directory in the archive contains an index.html page that file is returned instead of the directory listing. If you'd like to view files use a query string:

  • View files: http://archive-example.com/?viewSource=true

CLI

There is also a CLI that can be used for demo + testing. Pass it a dat link or a path to an existing dat folder:

node cli.js <dat-key>
node cli.js /path/do/existing/dat

hyperdrive-http's People

Contributors

aschrijver avatar creationix avatar edsilv avatar greenkeeper[bot] avatar joehand avatar juliangruber avatar mafintosh avatar millette avatar ninabreznik avatar rangermauve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperdrive-http's Issues

`/foo/` does not serve '/foo/index.html`, `/foo` does not serve `/foo.html`

Using dat-gateway to browse the web, which depends on hyperdrive-http, we've discovered a couple of path resolutions that websites expect servers to practice that hyperdrive-http does not. For example, see http://gateway.mauve.moe:3000/pfrazee.hashbase.io/ and click on a link on the first link and you'll end up at http://82kzddgmfbk9bf5wzx1jyu2cfeujj7n37718r5unh5pdxe0bubwg.gateway.mauve.moe:3000/blog/universal-publishing-and-the-webs-black-boxes

Now if you add HTML to the end, you'll see it does resolve. http://82kzddgmfbk9bf5wzx1jyu2cfeujj7n37718r5unh5pdxe0bubwg.gateway.mauve.moe:3000/blog/universal-publishing-and-the-webs-black-boxes.html

The other example is if you have a file at /foo/index.htmlt, if you try to go to /foo/ it will not give you /foo/index.html.

document URLs

  • What we accept with key
  • Changes thing
  • single archive URLs

split the methods out so that we can use custom routes

For example, adding a few functions: .get(key).pipe(res), .file(key, filename).pipe(res)

var hyperdrivehttp = require('hyperdrive-http')
var express = require('express')

var router = express()
var drive = hyperdrivehttp(getArchive)

router.get('/hi/:key', function (req, res) {
  drive.get(req.params.key).pipe(res)
})

An in-range update of hyperdrive is breaking the build 🚨

Version 7.14.0 of hyperdrive just got published.

Branch Build failing 🚨
Dependency hyperdrive
Current Version 7.13.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As hyperdrive is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Commits

The new version differs by 2 commits .

  • b71c80b 7.14.0
  • eb0b9fe only download latest files when using the file option

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

sodium.crypto_kdf_derive_from_key

hi,

I run node example.js and get:

`sodium.crypto_kdf_derive_from_key(seed, 1, context, secretKey)

Error: "key" must be crypto_kdf_KEYBYTES bytes long`

Use template inside a dat to style the file listing

[16:18:39]  <TheLink> still would be nice if the http option would take an optional template so you can make it pretty
[16:19:38]  <TheLink> + human readable sizes etc
[16:20:11]  <TheLink> or someone does a hyperbox module that does the whole dropbox thing
[16:20:47]  <@mafintosh> TheLink: how would that work?
[16:20:51]  <@mafintosh> TheLink: ohhhhh idea!!!!
[16:21:02]  <@mafintosh> TheLink: what if it looked for a template *inside* the dat???
[16:21:06]  <@mafintosh> how cool would that be
[16:21:12]  <TheLink> mafintosh: that would be awsome
[16:21:22]  <@mafintosh> TheLink: open an issue on that. i wanna do that

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.