Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beakerbrowser/hashbase
A Dat-hosting service for multiple users
https://github.com/beakerbrowser/hashbase
beaker dat
Last synced: 6 days ago
JSON representation
A Dat-hosting service for multiple users
- Host: GitHub
- URL: https://github.com/beakerbrowser/hashbase
- Owner: beakerbrowser
- License: mit
- Archived: true
- Created: 2017-06-07T19:26:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-07T17:12:29.000Z (over 2 years ago)
- Last Synced: 2024-08-02T10:27:18.298Z (3 months ago)
- Topics: beaker, dat
- Language: JavaScript
- Homepage: https://hashbase.io
- Size: 2.7 MB
- Stars: 239
- Watchers: 16
- Forks: 38
- Open Issues: 44
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dat - hashbase - hosting for the peer-to-peer web (Using Dat / Hosting & Dat Management)
- awesome-starred - beakerbrowser/hashbase - A Dat-hosting service for multiple users (others)
README
# Hashbase
Hashbase is a public peer service for [Dat](https://datproject.org) archives. It provides a HTTP-accessible interface for creating an account and uploading Dats. It was created to power a content-community for the [Beaker Browser](https://beakerbrowser.com)
Links:
- **[Hashbase.io](https://hashbase.io)**
- **[Documentation](./docs)**## Setup
On some platforms, you will need to have the following dependencies installed:
```
make
g++
python
autoconf
libtool
```Clone this repository, then run
```
npm install
cp config.defaults.yml config.development.yml
```Modify `config.development.yml` to fit your needs, then start the server with `npm start`.
## Configuration
Before deploying the service, you absolutely *must* modify the following config.
#### Basics
```yaml
dir: ./.hashbase # where to store the data
brandname: Hashbase # the title of your service
hostname: hashbase.local # the hostname of your service
proxy: true # is there a reverse proxy (eg nginx) in front of the server?
port: 8080 # the port to run the service on
rateLimiting: true # rate limit the HTTP requests?
csrf: true # use csrf tokens?
defaultDiskUsageLimit: 100mb # default maximum disk usage for each user
defaultNamedArchivesLimit: 25 # how many names can a user take?
bandwidthLimit:
up: 1mb # maximum bytes/s upload speed
down: 1mb # maximum bytes/s download speed
```#### Lets Encrypt
You can enable lets-encrypt to automatically provision TLS certs using this config:
```yaml
letsencrypt:
debug: false # debug mode? must be set to 'false' to use live config
agreeTos: true
email: '[email protected]' # email to register domains under
```If enabled, `port` will be ignored and the server will register at ports 80 and 443.
#### Admin Account
The admin user has its credentials set by the config yaml at load. If you change the password while the server is running, then restart the server, the password will be reset to whatever is in the config.
```yaml
admin:
email: '[email protected]'
password: myverysecretpassword
```#### HTTP Sites
Hashbase can host the archives as HTTP sites. This has the added benefit of enabling [dat-dns shortnames](https://npm.im/dat-dns) for the archives.
```yaml
sites: per-archive
```This will host archives at `archivename.hostname`. By default, HTTP Sites are disabled.
#### Closed Registration
For a private instance, use closed registration with a whitelist of allowed emails:
```yaml
registration:
open: false
allowed:
- [email protected]
- [email protected]
```#### Reserved Usernames
Use reserved usernames to blacklist usernames which collide with frontend routes, or which might be used maliciously.
```yaml
registration:
reservedNames:
- admin
- root
- support
- noreply
- users
- archives
```#### Monitoring
```yaml
pm2: false # set to true if you're using https://keymetrics.io/
alerts:
diskUsage: 10gb # when to trigger an alert on disk usage
```#### Session Tokens
Hashbase uses Json Web Tokens to manage sessions. You absolutely *must* replace the `secret` with a random string before deployment.
```yaml
sessions:
algorithm: HS256 # probably dont update this
secret: THIS MUST BE REPLACED! # put something random here
expiresIn: 1h # how long do sessions live?
```#### Jobs
Hashbase runs some jobs periodically. You can configure how frequently they run.
```yaml
# processing jobs
jobs:
popularArchivesIndex: 30s # compute the index of archives sorted by num peers
userDiskUsage: 5m # compute how much disk space each user is using
deleteDeadArchives: 5m # delete removed archives from disk
```#### Cache sizes (advanced)
You can tweak hashbase's memory usage to trade speed against memory usage.
```yaml
# cache settings
cache:
metadataStorage: 65536 # number of memory slots
contentStorage: 65536 # number of memory slots
tree: 65536 # number of memory slots
```#### Emailer
Hashbase relies on [NodeMailer](https://nodemailer.com/about/) to send out mails _(for example: required to verify a new user)_. The `email` property of the configuration will be passed _as-is_ to NodeMailer.
In the [default configuration](./config.defaults.yml#L46-L49) we use the [`stub`](https://www.npmjs.com/package/nodemailer-stub) transport which [offers a code API for tests](https://github.com/LimeDeck/nodemailer-stub/blob/8f03f86828de75ee2ccc32b98c8bc3d78e6abb00/lib/stubTransport.js#L44-L46).
```yaml
# email settings
email:
transport: stub
sender: '"Hashbase" '
````hashbase` has a dependency on the [`ses`](https://www.npmjs.com/package/nodemailer-ses-transport) and [`smtp`](https://www.npmjs.com/package/nodemailer-smtp-transport) transport, which means you can use those out-of-the-box. For other transports you need to install those first.
## Tests
Run the tests with
```
npm test
```To run the tests against a running server, specify the env var:
```
REMOTE_URL=http://{hostname}/ npm test
```## License
MIT