# hyperserver

> Framework for building your own P2P network

Latest version **0.0.5** (published 2017-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install hyperserver
pnpm add hyperserver
yarn add hyperserver
bun add hyperserver
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2017-11-04 |
| First published | 2017-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kevin Karsopawiro |
| Maintainers | afterburn |
| Keywords | peers, peer to peer, p2p, gossip, seeds, event passing, distributed, cluster, scaling, scale, stream, streams |

## Links

- npm: https://www.npmjs.com/package/hyperserver
- Homepage: https://github.com/afterburn/hyperserver#readme
- Issues: https://github.com/afterburn/hyperserver/issues
- npm.io page: https://npm.io/package/hyperserver

## Dependencies (2)

- [netmask](https://npm.io/package/netmask.md) *
- [nssocket](https://npm.io/package/nssocket.md) *

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2017-11-04
- 0.0.4 — 2017-11-04
- 0.0.3 — 2017-10-29
- 0.0.2 — 2017-10-29
- 0.0.1 — 2017-10-29

## README

# HyperServer
**THIS IS A WORK IN PROGRESS PROJECT**

HyperServer is a light-weight library for building both large and small scale peer-to-peer _(P2P)_ networks. It does not implement P2P data replication for you. It is simply a plain, flexible peer-to-peer networking solution, onto which you can easily build your own replication model or use some kind of event passing mechanism.

### Installation
```
npm install hyperserver
```

### System overview
When attempting to join a P2P network, specific discovery or membership protocols (or other configuration information) may be required, and, if a newly joining node is unaware of these protocols, the newly established joining node will not be able to communicate with other nodes and ultimately join the network.

This is why we need **_bootstrapping nodes_**; to provide the initial required information to a newly joined node so that it knows how to proceed connecting to other nodes.
There are two types of nodes/peers you can create with this library: **_bootstrapping nodes_** and default **_nodes_**.

### Usage
```javascript
const hyperserver = require('hyperserver');

const node = hyperserver.createNode({
    ip: '192.168.0.1/255.255.255.0',
    port: 3000,
    bootstrap: true, // Assign the node to be a bootstrapping node.
    seeds: [ // List of endpoints to which the node should initially connect.
        { "address": "192.168.0.17", "port": 3000 }
    ]
});
```

#### Events
```javascript
node.on('available', () => {
    // Fires when there are peers available.
});

node.on('unavailable', () => {
    // Fires when there are no peers available anymore.
});

node.on('connect', (peer) => {
    // Fires when a peer connects to this node.
});

node.on('disconnect', (peer) => {
    // Fires when a peer disconnects from this node.
});

node.on('data', (data, peer) => {
    // Fires when a message is received from a certain peer.
});
```

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