@ubiquify/relay
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

@ubiquify/relay

Relay for Ubiquify applications. Forked from O7-R.

Usage

As library.

import { BlockStore, memoryBlockStoreFactory } from "@ubiquify/core";
import {
  LinkResolver,
  memoryBlockResolverFactory,
  getCertificate,
  createGraphRelay,
} from "@ubiquify/relay";

const blockStore: BlockStore = memoryBlockStoreFactory();
const linkResolver: LinkResolver = memoryBlockResolverFactory();
const httpsPort = 3003;
const graphRelay = createGraphRelay(blockStore, linkResolver);
graphRelay.startHttps(3000, getCertificate(), () => {
  console.log(`GraphRelay listening on https://localhost:${httpsPort}`);
});
const httpPort = 3001;
graphRelay.startHttp(httpPort, () => {
  console.log(`GraphRelay listening on http://localhost:${httpPort}`);
});

Standalone.

npm start

SSL

The relay expects two files in the ssl folder:

  • server.key - Private key.
  • server.crt - Certificate.

A self signed certificate can be generated in linux with openssl:

cd ssl/
openssl req -nodes -new -x509 -keyout server.key -out server.crt

Build

npm run clean
npm install
npm run build
npm run test

Licenses

Licensed under either Apache 2.0 or MIT at your option.

Readme

Keywords

Package Sidebar

Install

npm i @ubiquify/relay

Weekly Downloads

1

Version

0.0.15

License

(Apache-2.0 AND MIT)

Unpacked Size

60.4 kB

Total Files

37

Last publish

Collaborators

  • ubiquify