-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmod.ts
59 lines (58 loc) · 1.82 KB
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* [Earthstar](https://earthstar-project.org) is a small and resilient distributed storage protocol designed with a strong focus on simplicity and versatility, with the social realities of peer-to-peer computing kept in mind.
*
* This is a reference implementation written in Typescript. You can use it to add Earthstar functionality to applications running on servers, browsers, the command line, or anywhere else JavaScript can be run.
*
* ### Example usage
*
* ```ts
* import { Replica, ReplicaDriverMemory, Crypto, Peer } from "earthstar";
*
* const shareKeypair = await Crypto.generateShareKeypair("gardening");
*
* const replica = new Replica({
* driver: ReplicaDriverMemory(shareKeypair.shareAddress),
* shareSecret: shareKeypair.secret,
* });
*
* const authorKeypair = await Crypto.generateAuthorKeypair("suzy");
*
* await replica.set(authorKeypair, {
* path: "/my-note",
* text: "Saw seven magpies today",
* });
*
* const allDocs = await replica.getAllDocs();
*
* const peer = new Peer();
*
* peer.addReplica(replica);
*
* peer.sync("https://my.server")
* ```
*
* This module also exposes server APIs for for building always-online peers. The below example reads some on-disk JSON to initiate some share replicas, and stores their data using the filesystem.
*
* ```ts
* import {
* ExtensionKnownShares,
* ExtensionSyncWeb,
* Server,
* } from "https://deno.land/x/earthstar/mod.ts";
*
* const server = new Server([
* new ExtensionKnownShares({
* knownSharesPath: "./known_shares.json",
* onCreateReplica: (shareAddress) => {
* return new Earthstar.Replica({
* driver: new ReplicaDriverFs(shareAddress, "./share_data"),
* });
* },
* }),
* new ExtensionSyncWebsocket(),
* ]);
*
* @module
*/
export * from "./src/entries/universal.ts";
export * from "./src/entries/deno.ts";