# swarm-server

> A simple LevelDB-backed WebSocket and TCP-listening Swarm server (peer).

Latest version **1.2.1** (published 2016-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install swarm-server
pnpm add swarm-server
yarn add swarm-server
bun add swarm-server
```

Provides the command `swarmd`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2016-09-29 |
| First published | 2015-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2664 |
| Author | Victor Grishchenko |
| Maintainers | gritzko |

## Links

- npm: https://www.npmjs.com/package/swarm-server
- Repository: https://github.com/gritzko/swarm
- Homepage: http://github.com/gritzko/swarm
- Issues: https://github.com/gritzko/swarm/issues
- npm.io page: https://npm.io/package/swarm-server

## Dependencies (7)

- [daemon](https://npm.io/package/daemon.md) ^1.1.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [leveldown](https://npm.io/package/leveldown.md) ^1.4.6
- [swarm-cli](https://npm.io/package/swarm-cli.md) ^1.2.0
- [swarm-peer](https://npm.io/package/swarm-peer.md) ^1.2.0
- [swarm-protocol](https://npm.io/package/swarm-protocol.md) ^1.2.0
- [swarm-syncable](https://npm.io/package/swarm-syncable.md) ^1.2.0

## Recent versions

- 1.2.1 (latest) — 2016-09-29
- 1.0.7 (nightly) — 2015-12-23
- 1.0.19 — 2016-01-13
- 1.0.17 — 2016-01-06
- 1.0.16 — 2016-01-03
- 1.0.15 — 2015-12-31
- 1.0.14 — 2015-12-28
- 1.0.12 — 2015-12-25
- 1.0.5 — 2015-12-17
- 1.0.1 — 2015-12-01

## README

# Swarm: a basic server

A simple LevelDB-backed WebSocket and TCP-listening Swarm server (peer).

## Usage

    swarmd [-C|-F|-A|-R] [options] path/database-id

C, F, A, R are run modes (create, fork, access, run).
The database directory name consists of the database id and peer id.

```bash

npm install -g swarm-server
    
# creates an empty "test" database replica (peer id 1) at ./test-1
swarmd -C --oClock=Logical ./test-1

# WebSocket-only Swarm server, runs REPL, which is good for debugging
swarmd -R ./test-1 --listen ws://localhost:8080
```

## Options

- [x] `-C --create` create a database (dir name == db name)
    - [x] `-n --name` database name (default: take from the path)
    - [ ] `-i --id XY` replica id (default: take from the path)
    - [x] `--oXxx="Yyy"` set a global database option Xxx to "Yyy"
    - [ ] `--OXxx="Yyy"` set a scoped database option 
    - [ ] `--0Xxx="Yyy"` set a local database option override
- [ ] `-F --fork` fork a database
    - [ ] `-t --to /path/dbname-YZ` a path for the new replica
    - [ ] `-i --id YZ` as above
- [x] `-A --access` access a database
    - [ ] `-s --scan /Type#id!prefix` list all records under a prefix
    - [x] `-e --erase /Type#id!prefix` erase records
    - [x] `-p --put file` add ops to the database (default: read stdin)
    - [x] `-v --vv` print the version vector
    - [ ] `-g --get /Type#id` print the object's state 
    - [ ] `--OXxx, --0Xxx` edit database options (as above)
- [x] `-U --user` add/remove/list users/clients
    - [x] `-a --add login` add a user (take the password from stdin)
    - [x] `-r --remove login`
    - [x] `-l --list`
- [ ] `-R --run` run a database (the default)
    - [ ] `-l --listen scheme:url` listen for client conns on URL
        - [x] `-` stdin (default)
        - [ ] `ws://hostname:port` WebSocket
        - [ ] `tcp://11.22.33.44:5555` TCP
    - [ ] `-c --connect scheme:url` connect to a peer
    - [ ] `-e --exec script.js` execute a script once connected
    - [ ] `-r --repl` start REPL
    - [ ] `-d --daemon` daemonize
    - [ ] `-x` exit when done
    - [ ] `-f --filter` grep log events (e.g. `-f /Swarm.on.off`)

## Database options

1. Globals (relayed to every replica)
    - [x] `DBIdScheme` replica id scheme (e.g. `--oIdScheme=0280`)
    - [x] `Clock` clock mode (`Logical`, `Hybrid`)
    - [x] `ClockLen` minimum time value length (e.g. 6 for `1GDBdW`)
2. Scopeds (relayed to clients, but not peers)
3. Locals (not relayed)
    - [ ] `Listen` listen url (e.g. `-0Listen=wss://swarmdb.net:1234`)
    - [ ] `Connect` peer's url (e.g. `-0Connect=tcp://1.2.3.4:5678`)


for a CLI client, see `swarm-client`.

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