# hyperdrive-http

> Handle Hyper[drive|core] HTTP Requests

Latest version **4.4.1** (published 2022-01-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install hyperdrive-http
pnpm add hyperdrive-http
yarn add hyperdrive-http
bun add hyperdrive-http
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.4.1 |
| Published | 2022-01-06 |
| First published | 2016-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 22.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 67 |
| Author | Joe Hand |
| Maintainers | karissa, maxogden, yoshuawuyts, mafintosh, jhand, rangermauve, leichtgewicht, the-real-dk, pfrazee, frando, cblgh, ninabreznik, serapath, zootella, juliangruber |
| Keywords | hypercore, hyperdrive, dat |

## Links

- npm: https://www.npmjs.com/package/hyperdrive-http
- Repository: https://github.com/joehand/hyperdrive-http
- Issues: https://github.comm/joehand/hyperdrive-http/issues
- npm.io page: https://npm.io/package/hyperdrive-http

## Dependencies (5)

- [mime](https://npm.io/package/mime.md) ^2.3.1
- [pump](https://npm.io/package/pump.md) ^3.0.0
- [corsify](https://npm.io/package/corsify.md) ^2.1.0
- [range-parser](https://npm.io/package/range-parser.md) ^1.2.0
- [directory-index-html](https://npm.io/package/directory-index-html.md) ^2.1.0

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 4.4.1 (latest) — 2022-01-06
- 4.2.1 (old-version) — 2017-10-09
- 4.4.0 — 2019-02-16
- 4.3.4 — 2018-11-14
- 4.3.3 — 2018-08-08
- 4.3.2 — 2018-07-06
- 4.3.1 — 2018-07-04
- 4.3.0 — 2018-07-04
- 4.2.2 — 2017-10-10
- 4.2.0 — 2017-05-18
- 4.1.1 — 2017-05-12
- 4.1.0 — 2017-05-11
- 4.0.1 — 2017-04-06
- 4.0.0 — 2017-04-06
- 3.5.0 — 2017-03-14
- … 10 more at https://npm.io/package/hyperdrive-http/versions

## README

[![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](https://dat-ecosystem.org/) 

More info on active projects and modules at [dat-ecosystem.org](https://dat-ecosystem.org/) <img src="https://i.imgur.com/qZWlO1y.jpg" width="30" height="30" /> 

---

# Hyperdrive Http

Serve a [hyperdrive](https://github.com/mafintosh/hyperdrive) archive over HTTP. For an example of use, see [dat.haus](https://github.com/juliangruber/dat.haus).

[![Travis](https://api.travis-ci.org/joehand/hyperdrive-http.svg)](https://travis-ci.org/joehand/hyperdrive-http)

## Usage

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

```js
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`):
  ```http
  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
```

---
_Source: https://npm.io/package/hyperdrive-http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
