README
This commit is contained in:
parent
cbec1b5afb
commit
85398249fd
52
README.md
52
README.md
|
@ -1,2 +1,52 @@
|
||||||
# rhizome
|
## Setup
|
||||||
|
|
||||||
|
Install nodejs
|
||||||
|
Install [nvm](https://nvm.sh)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nvm install
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx tsc
|
||||||
|
# npm run build # also works
|
||||||
|
|
||||||
|
# npx tsc --watch # is useful during development
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
To demonstrate the example application, you can open multiple terminals. In each terminal execute something like the following.
|
||||||
|
|
||||||
|
export RHIZOME_REQUEST_BIND_PORT=4000
|
||||||
|
export RHIZOME_PUBLISH_BIND_PORT=4001
|
||||||
|
export RHIZOME_SEED_PEERS='127.0.0.1:4002, 127.0.0.1:4004'
|
||||||
|
export RHIZOME_HTTP_API_PORT=3000
|
||||||
|
export RHIZOME_PEER_ID=peer1
|
||||||
|
node dist/example-app.js
|
||||||
|
|
||||||
|
export RHIZOME_REQUEST_BIND_PORT=4002
|
||||||
|
export RHIZOME_PUBLISH_BIND_PORT=4003
|
||||||
|
export RHIZOME_SEED_PEERS='127.0.0.1:4000, 127.0.0.1:4004'
|
||||||
|
export RHIZOME_PEER_ID=peer2
|
||||||
|
node dist/example-app.js
|
||||||
|
|
||||||
|
export RHIZOME_REQUEST_BIND_PORT=4004
|
||||||
|
export RHIZOME_PUBLISH_BIND_PORT=4005
|
||||||
|
export RHIZOME_SEED_PEERS='127.0.0.1:4000, 127.0.0.1:4002'
|
||||||
|
export RHIZOME_PEER_ID=peer3
|
||||||
|
node dist/example-app.js
|
||||||
|
|
||||||
|
In a separate terminal, you can use `curl` to interact with an instance.
|
||||||
|
|
||||||
|
`jq` is helpful for formatting the json responses.
|
||||||
|
|
||||||
|
curl -s http://localhost:3000/peers/count | jq
|
||||||
|
curl -s http://localhost:3000/peers | jq
|
||||||
|
curl -s http://localhost:3000/deltas/count | jq
|
||||||
|
curl -s http://localhost:3000/deltas | jq
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
To install
|
|
||||||
|
|
||||||
npm install
|
|
||||||
|
|
||||||
To build
|
|
||||||
|
|
||||||
npx tsc
|
|
||||||
|
|
||||||
To demonstrate the example application, you can open multiple terminals. In each terminal execute something like the following.
|
|
||||||
|
|
||||||
export REQUEST_BIND_PORT=4000
|
|
||||||
export PUBLISH_BIND_PORT=4001
|
|
||||||
export SEED_PEERS='127.0.0.1:4002, 127.0.0.1:4004'
|
|
||||||
node dist/example-app.js
|
|
||||||
|
|
||||||
export REQUEST_BIND_PORT=4002
|
|
||||||
export PUBLISH_BIND_PORT=4003
|
|
||||||
export SEED_PEERS='127.0.0.1:4000, 127.0.0.1:4004'
|
|
||||||
node dist/example-app.js
|
|
||||||
|
|
||||||
export REQUEST_BIND_PORT=4004
|
|
||||||
export PUBLISH_BIND_PORT=4005
|
|
||||||
export SEED_PEERS='127.0.0.1:4000, 127.0.0.1:4002'
|
|
||||||
node dist/example-app.js
|
|
|
@ -1,18 +1,21 @@
|
||||||
import {randomUUID} from "crypto";
|
import {randomUUID} from "crypto";
|
||||||
import {PeerAddress} from "./types";
|
import {PeerAddress} from "./types";
|
||||||
|
|
||||||
|
// _HOST refers to the address from an external perspective
|
||||||
|
// _ADDR refers to the interface address from the service's perspective
|
||||||
|
|
||||||
export const LEVEL_DB_DIR = process.env.RHIZOME_LEVEL_DB_DIR ?? './data';
|
export const LEVEL_DB_DIR = process.env.RHIZOME_LEVEL_DB_DIR ?? './data';
|
||||||
export const CREATOR = process.env.USER!;
|
export const CREATOR = process.env.USER!;
|
||||||
export const HOST_ID = process.env.RHIZOME_PEER_ID || randomUUID();
|
export const HOST_ID = process.env.RHIZOME_PEER_ID || randomUUID();
|
||||||
export const ADDRESS = process.env.RHIZOME_ADDRESS ?? '127.0.0.1';
|
export const ADDRESS = process.env.RHIZOME_ADDRESS ?? 'localhost';
|
||||||
|
export const REQUEST_BIND_ADDR = process.env.RHIZOME_REQUEST_BIND_ADDR || ADDRESS;
|
||||||
export const REQUEST_BIND_PORT = parseInt(process.env.RHIZOME_REQUEST_BIND_PORT || '4000');
|
export const REQUEST_BIND_PORT = parseInt(process.env.RHIZOME_REQUEST_BIND_PORT || '4000');
|
||||||
export const REQUEST_BIND_ADDR = process.env.RHIZOME_REQUEST_BIND_ADDR || ADDRESS || '127.0.0.1';
|
export const REQUEST_BIND_HOST = process.env.RHIZOME_REQUEST_BIND_HOST || REQUEST_BIND_ADDR;
|
||||||
export const REQUEST_BIND_HOST = process.env.RHIZOME_REQUEST_BIND_HOST || REQUEST_BIND_ADDR || '127.0.0.1';
|
export const PUBLISH_BIND_ADDR = process.env.RHIZOME_PUBLISH_BIND_ADDR || ADDRESS;
|
||||||
export const PUBLISH_BIND_PORT = parseInt(process.env.RHIZOME_PUBLISH_BIND_PORT || '4001');
|
export const PUBLISH_BIND_PORT = parseInt(process.env.RHIZOME_PUBLISH_BIND_PORT || '4001');
|
||||||
export const PUBLISH_BIND_ADDR = process.env.RHIZOME_PUBLISH_BIND_ADDR || ADDRESS || '127.0.0.1';
|
export const PUBLISH_BIND_HOST = process.env.RHIZOME_PUBLISH_BIND_HOST || PUBLISH_BIND_ADDR;
|
||||||
export const PUBLISH_BIND_HOST = process.env.RHIZOME_PUBLISH_BIND_HOST || PUBLISH_BIND_ADDR || '127.0.0.1';
|
|
||||||
export const HTTP_API_PORT = parseInt(process.env.RHIZOME_HTTP_API_PORT || '3000');
|
|
||||||
export const HTTP_API_ADDR = process.env.RHIZOME_HTTP_API_ADDR || ADDRESS || '127.0.0.1';
|
export const HTTP_API_ADDR = process.env.RHIZOME_HTTP_API_ADDR || ADDRESS || '127.0.0.1';
|
||||||
|
export const HTTP_API_PORT = parseInt(process.env.RHIZOME_HTTP_API_PORT || '3000');
|
||||||
export const HTTP_API_ENABLE = process.env.RHIZOME_HTTP_API_ENABLE === 'true';
|
export const HTTP_API_ENABLE = process.env.RHIZOME_HTTP_API_ENABLE === 'true';
|
||||||
export const SEED_PEERS: PeerAddress[] = (process.env.RHIZOME_SEED_PEERS || '').split(',')
|
export const SEED_PEERS: PeerAddress[] = (process.env.RHIZOME_SEED_PEERS || '').split(',')
|
||||||
.filter(x => !!x)
|
.filter(x => !!x)
|
||||||
|
|
Loading…
Reference in New Issue