In-memory Dat to HTTP gateway
Clone or download
#8 Compare This branch is 50 commits ahead, 2 commits behind pfrazee:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.datignore
.gitignore
.travis.yml
README.md
bin.js
index.html
index.js
package.json
test.js

README.md

dat-gateway

Stability NPM Version JavaScript Style Guide Build Status Coverage Status

A configurable in-memory Dat-to-HTTP gateway, so you can visit Dat archives from your browser.

If you want a browser that can visit Dat archives, check out Beaker.

Install

To get the dat-gateway command for running your own gateway, use npm:

npm i -g dat-gateway

Usage

You can run dat-gateway to start a gateway server that listens on port 3000. You can also configure it! You can print usage information with dat-gateway -h:

$ dat-gateway -h
dat-gateway

Options:
  --version   Show version number                                      [boolean]
  --config    Path to JSON config file
  --port, -p  Port for the gateway to listen on.                 [default: 3000]
  --dir, -d   Directory to use as a cache.  [string] [default: "~/.dat-gateway"]
  --max, -m   Maximum number of archives allowed in the cache.     [default: 20]
  --period    Number of milliseconds between cleaning the cache of expired
              archives.                                         [default: 10000]
  --ttl, -t   Number of milliseconds before archives expire.   [default: 600000]
  -h, --help  Show help                                                [boolean]

You can visit Dat archives through the gateway using a route like this:

http://localhost:3000/{datKey}/{path...}

For example:

http://localhost:3000/40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/assets/img/beaker-0.7.gif

The gateway will even resolve URLs using Dat-DNS:

http://localhost:3000/garbados.hashbase.io/icons/favicon.ico

The gateway will peer archives until they expire from the cache, at which point it proactively halts them and deletes them from disk.

Contributions

All contributions are welcome: bug reports, feature requests, "why doesn't this work" questions, patches for fixes and features, etc. For all of the above, file an issue or submit a pull request.

License

Apache-2.0