npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openrealm/web

v0.7.0

Published

**Deprecation Notice:** grpc-web has been deprecated and is no longer supported. Please use the [HTTP API](./README.md) instead. This original document has been kept only for historical reference.

Downloads

3

Readme

@openrealm/hub-web

Deprecation Notice: grpc-web has been deprecated and is no longer supported. Please use the HTTP API instead. This original document has been kept only for historical reference.

A lightweight, fast Typescript interface for Openrealm Hubs. Designed to work with Hubble and any other Hub that implements the Openrealm protocol.

Features

  • Call any Hub endpoint from a browser environment using gRPC-Web.
  • Serializes and deserializes Openrealm protobufs into Javascript objects.
  • Has helpers to create and sign Openrealm messages.
  • Written entirely in TypeScript, with strict types for safety.

Installation

Install @openrealm/hub-web with the package manager of your choice

npm install @openrealm/hub-web
yarn add @openrealm/hub-web
pnpm install @openrealm/hub-web

Documentation

The @openrealm/hub-web APIs are largely the same as @openrealm/hub-nodejs. Read the @openrealm/hub-nodejs documentation and browse code examples. We're also including sample @openrealm/hub-web code below as well as a list of differences with the other package.

Getting start: fetching casts

import { getHubRpcClient } from '@openrealm/hub-web';

(async () => {
  const client = getHubRpcClient('https://testnet1.openrealm.xyz:2285');

  const castsResult = await client.getCastsByQid({ qid: 15 });

  castsResult.map((casts) => casts.messages.map((cast) => console.log(cast.data?.castAddBody?.text)));
})();

Instantiating a client

The method to construct a Hub gRPC client differs from @openrealm/hub-nodejs. Use getHubRpcClient, which returns a Hub gRPC-Web client. Make sure that the gRPC server you're connecting to implements a gRPC-Web proxy. The standard is to expose the gRPC-Web proxy at port 2285.

Usage

import { getHubRpcClient } from '@openrealm/hub-web';

(async () => {
  const client = getHubRpcClient('https://testnet1.openrealm.xyz:2285');

  // If you're using gRPC-Web from a Nodejs environment, add a second false parameter
  // const nodeClient = getHubRpcClient('https://testnet1.openrealm.xyz:2285', false);
})();

Returns

| Type | Description | | :------------- | :------------------------------ | | HubRpcClient | A new gRPC-Web Client instance. |

Parameters

| Name | Type | Description | | :---------- | :-------- | :------------------------------------------------------------------------- | | url | string | Address and RPC port string (e.g. https://testnet1.openrealm.xyz:2285) | | isBrowser | boolean | Optional parameter indicating whether to use the gRPC-Web Nodejs transport |

Streaming hub events

gRPC-Web hub event streams are instances of the Observable class in @openrealm/hub-web.

Usage

import { getHubRpcClient } from '@openrealm/hub-web';

async () => {
  const client = getHubRpcClient('https://testnet1.openrealm.xyz:2285');

  const result = client.subscribe({ eventTypes: [HubEventType.PRUNE_MESSAGE], fromId: 0 });

  result.map((observable) => {
    observable.subscribe({
      next(event: HubEvent) {
        console.log('received event', event);
      },
      error(err) {
        console.error(err);
      },
    });
  });
};

Returns

| Type | Description | | :-------------------------------- | :---------------------------------------------------------------------------- | | HubResult<Observable<HubEvent>> | An Observable stream wrapped in a Result |

Parameters

| Name | Type | Description | | :----------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | fromId | number | (Optional) ID of the hub event to start streaming from. A fromId of 0 will stream all events from the hub, and passing no fromId will start the stream from the present moment. | | eventTypes | HubEventType[] | Array of hub event types to return. If eventTypes is [], all event types will be returned. |

License

MIT License