# @dhub/mirroring-service

> A dHub service with an RPC API for mirroring.

Latest version **1.0.2** (published 2021-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dhub/mirroring-service
pnpm add @dhub/mirroring-service
yarn add @dhub/mirroring-service
bun add @dhub/mirroring-service
```

## 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.0.2 |
| Published | 2021-03-25 |
| First published | 2021-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 27.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | PeepsLabs |
| Maintainers | dwebprotocol |
| Keywords | dhub, seeding, mirroring |

## Links

- npm: https://www.npmjs.com/package/@dhub/mirroring-service
- Repository: https://github.com/dwebprotocol/dhub-mirroring-service
- Homepage: https://dwebx.org
- Issues: https://github.com/dwebprotocol/dhub-mirroring-service/issues
- npm.io page: https://npm.io/package/@dhub/mirroring-service

## Dependencies (6)

- [ddrive](https://npm.io/package/ddrive.md) ^5.0.0
- [dwebtree](https://npm.io/package/dwebtree.md) ^1.0.0
- [drpc_dweb](https://npm.io/package/drpc_dweb.md) ^1.0.0
- [@dhub/client](https://npm.io/package/@dhub/client.md) ^1.0.0
- [drpc_dweb-runtime](https://npm.io/package/drpc_dweb-runtime.md) ^1.0.0
- [nanoresource-promise](https://npm.io/package/nanoresource-promise.md) ^2.0.0

## Recent versions

- 1.0.2 (latest) — 2021-03-25
- 1.0.0 — 2021-03-13

## README

# dhub-mirroring-service
A dHub service with a RPC API for mirroring.

## Installation
```
npm i dhub-mirroring-service
```

## Usage
This service is meant to run alongside a running dHub server.

With dHub running in a separate terminal:
```sh
❯ ./bin/index.js
Running dhub-mirror/1.0.6 linux-x64 node-v14.15.0
Listening on /tmp/dhub-mirroring.sock
```

Then you can import `dhub-mirroring-service/client` inside a script, and it will auto-connect to the running server.

The mirror service provides an [DRPC](https://github.com/dwebprotocol/drpc) endpoint with methods for mirroring, unmirror, and listing mirroed dDatabase-based data structures.

Currently it supports mirroring dDrives and individual DDatabases. It doesn't do data-structure detection by looking at DDatabase headers -- you gotta explicitly provide the type.

As of now, dDrive mirroring doesn't handle mounts. Maybe one day

## API

#### `await client.mirror(key, type)`
Start mirroring a dDatabase-based data structure.

This command will currently special-case the `ddrive` type, mirroring both metadata and content feeds.

#### `await client.unmirror(key, type)`
Stop mirroring a dDatabase-based data structure.

This command will currently special-case the `ddrive` type, unmirroring both metadata and content feeds.

#### `await client.status(key, type)`
Check if a data structure is being mirrored;

Returns an object of the form:
```js
{
  key, // Buffer
  type, // string
  mirroring // bool
}
```

#### `await client.list()`
List all data structures being mirrored.

Returns an Array of status objects with the same shape as the `status` return value.

#### `await client.stop()`
Shut down the server.

## License
MIT

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