Earthstar Streaming RPC
Very similar to JSON-RPC, but also supports streaming. Written to be used in Earthstar (github, docs).
This is a "Deno-first" package -- it's written for Deno, and then also converted and published to npm. It should also work from browsers -- typically you'd import it from your own separate npm project and use a bundler such as webpack to put everything together.
Code structure
Just the src
:
Everything:
Usage
To use in Deno, add the following:
import * as RPC from "https://TODO.com/earthstar-streaming-rpc/mod.ts";
To use with Node or apps built with NPM dependencies:
npm i earthstar-streaming-rpc
And then import in your code:
import * as RPC from "earthstar-streaming-rpc";
Development
Setup
You will need Deno installed. Instructions for installation can be found here. You may also want type-checking and linting from Deno for your IDE, which you can get with extensions like this one for VSCode.
To check that you've got everything set up correctly:
make example
This will run the example script at example-app.ts
, and you will see a lot of colourful log messages from the app.
Scripts
Scripts are run with the make
command.
make test
- Run all testsmake test-watch
- Run all tests in watch modemake fmt
- Format all code in the codebasemake npm
- Create a NPM package innpm
and run tests against it (requires Node v14 or v16 to be installed).make bundle
- Create a bundled browser script atearthstar.bundle.js
make depchart
- Regenerate the dependency chart imagesmake coverage
- Generate code test coverage statisticsmake clean
- Delete generated files
Orientation
- The entry for the package can be found at
mod.ts
. - Most external dependencies can be found in
deps.ts
. All other files import external dependencies from this file. - Script definitions can be found in
Makefile
. - Tests are all in
src/test/
- The script for building the NPM package can be found in
scripts/build_npm.ts
Publishing to NPM
- Run
make VERSION="version.number.here" npm
, whereversion.number.here
is the desired version number for the package. cd npm
npm publish