# browserve-host

> The point of this is to allow your browser to "host" files which can be streamed over HTTP. This requires a proxy server to handle the HTTP requests and forward them to the browser over websockets.

Latest version **0.7.0** (published 2018-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install browserve-host
pnpm add browserve-host
yarn add browserve-host
bun add browserve-host
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.0 |
| Published | 2018-11-10 |
| First published | 2018-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 303.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anders Pitman |
| Maintainers | anderspitman |

## Links

- npm: https://www.npmjs.com/package/browserve-host
- npm.io page: https://npm.io/package/browserve-host

## Dependencies (2)

- [filereader-stream](https://npm.io/package/filereader-stream.md) ^2.0.0
- [@anderspitman/ws-streamify](https://npm.io/package/@anderspitman/ws-streamify.md) ^0.1.3

## Recent versions

- 0.7.0 (latest) — 2018-11-10
- 0.6.0 — 2018-09-12
- 0.5.0 — 2018-09-12
- 0.4.0 — 2018-09-12
- 0.3.0 — 2018-09-11
- 0.2.0 — 2018-09-10
- 0.1.0 — 2018-09-06

## README

The point of this is to allow your browser to "host" files which can be
streamed over HTTP. This requires a proxy server to handle the HTTP requests
and forward them to the browser over websockets.

Why would this be useful? If the user has a very large file (genomic data files
can easily be in the 20GB-200GB range), and you want to make
[ranged requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests)
to that file (ie only download specific chunks) as though it were hosted on a
normal server, this will allow that.

NOTE: This is a very early work in progress and not intended to be used for
anything production ready at the moment.

# Example usage

First start up the proxy server. We'll assume it's publicly available at
example.com. It's currently hard-coded to listen for HTTP on port 7000 and
websocket connections on 8081.

```bash
node proxy/index.js
```

Create a "server" object in the browser:

```javascript
const host = "example.com";
const rsServer = new reverserver.Server({ host, port: 8081 });
```

"Host" a couple files in the browser. See `server/dist/index.html` for an
example where the user selects a file from their computer.

```javascript
const file1 = new File(["Hi there"], "file1.txt", {
  type: "text/plain",
});

const file2 = new File(["I'm Old Gregg"], "file2.txt", {
  type: "text/plain",
});

rsServer.hostFile('/file1', file1);
rsServer.hostFile('/file2', file2);
```

Retrieve the files using any http client:
```bash
curl example.com:7000/file1
Hi there
curl example.com:7000/file2
I'm Old Gregg
```

Ranged requests work too:
```bash
curl -H "Range: bytes=0-2" example.com:7000/file1
Hi
```

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