0.0.8 • Published 7 months ago

@freenetorg/freenet-stdlib v0.0.8

Weekly downloads
-
License
MIT+APACHE-2.0
Repository
github
Last release
7 months ago

Locutus Javascript/Typescript Std Lib

Locutus Javascript/Typescript Standard Library contains utilities for developing web apps which interact with Locutus node.

The stdlib offers a series of facilities in which you will be able to communicate with the network ergonomically.

Here is a minimal example of how you could write your application to interact with the node:

import {
  GetResponse,
  HostError,
  Key,
  FreenetWsApi,
  PutResponse,
  UpdateNotification,
  UpdateResponse,
} from "@freenetorg/freenet-stdlib/websocket-interface";

const handler = {
  onPut: (_response: PutResponse) => {},
  onGet: (_response: GetResponse) => {},
  onUpdate: (_up: UpdateResponse) => {},
  onUpdateNotification: (_notif: UpdateNotification) => {},
  onErr: (err: HostError) => {},
  onOpen: () => {},
};

const API_URL = new URL(`ws://${location.host}/contract/command/`);
const locutusApi = new FreenetWsApi(API_URL, handler);

const CONTRACT = "DCBi7HNZC3QUZRiZLFZDiEduv5KHgZfgBk8WwTiheGq1";

async function loadState() {
  let getRequest = {
    key: Key.fromSpec(CONTRACT),
    fetch_contract: false,
  };
  await locutusApi.get(getRequest);
}
0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.1

8 months ago