blossom-drive-webserver/README.md
2024-03-19 07:47:33 +01:00

72 lines
5.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🌸 blossom-drive-webserver
## Overview
This projects serves (static) web pages from a public blossom drive. Blossom drives are a nostr
based personal file storage. See it's documentation for more information:
- General Spec: https://github.com/hzrd149/blossom
- Drive UI: https://github.com/hzrd149/blossom-drive
- Nostr Event for a Drive: https://github.com/hzrd149/blossom-drive/blob/master/docs/drive.md
# Usage
## File storage
Files can be stored via the Drive web UI, which is currently hosted at https://blossom.hzrd149.com/
Each drive is identified by an address pointer, that can be seen in the URL, e.g.: `naddr1qvzqqqrhvvpzpd7x76g4e...amhxgaamr23`. This `naddr` can be used to reference the drive and publish it's contents on the web.
## Running the web server
When running this web server the contents of the drive are available at: `http://localhost:3000/naddr1qvzqqqrhvvpzpd7x76g4e...amhxgaamr23/`, i.e. a static web page stored in the drive will be hosted on this URL and can
be accessed in a browser.
## Configuration
| ENV Variable | Description | Default |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| PORT |  The Port on which the server listens for connections | ` 3000` |
| DEBUG | Sets the debug level / log output for components of the server. | `web*,koa*,ndk*` |
| SINGLE_SITE | A `naddr` pointing to a drive, that will be exclusively served on this server (single site mode). When left blank (default) all drive are available through a folder path e.g. `https://domain.name/naddr1e2w...9aee2sk9el27/` | |
| FOLDER_LISTING | When enabled the web server return a list of folder contents, when no `ìndex.html` file exists. |  `true` |
| DRIVE_PRELOAD | When enabled the server preloads a list of all public drive events from NOSTR and stores them im memory cache. This will speed up the first request for a drive. | `false` |
| DRIVE_REFRESH_INTERVAL | The interval in seconds how often the full lists of drives is fetched from the nostr relays. | `300` |
| DRIVE_REFRESH_TIMEOUT | Timeout for the Nostr Relay Connection in seconds | `10` |
| DRIVE_CACHE_TTL | Time in seconds content of the drives are cached for in memory | `3600` |
| CDN_CACHE_DIR | Local folder path where blobs are stored | ./cache |
| CDN_MAX_LOCAL_CACHE_SIZE | Defines a maximum file size in bytes. Files below this threshold are stored in the local cache folder. | `100000` |
| CDN_ADDITIONAL_SERVERS | Comma separated list of blossom blob storage servers that are used in addition to those defined in the drive event (as `r` tags). | `https://cdn.hzrd149.com,` `https://cdn.satellite.earth` |
| NOSTR_DEFAULT_RELAYS | Comma separated list of NOSTR relays that are use in addition to relays defined in the `naddr`. | `wss://nostrue.com,` `wss://relay.damus.io,` `wss://nos.lol` |
## Build
### Local nodejs
This project is built on NodeJS, i.e. the usual commands apply:
```sh
npm install
npm run build
```
```sh
npm start
```
### Docker
```sh
docker build -t blosson-drive-webserver .
```
```sh
docker run -it --rm -p 3000:3000 blosson-drive-webserver
```
```sh
docker run -p 3000:3000 blosson-drive-webserver
```