• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Metarhia Logo

Travis CI AppVeyor CI Coverage Status NPM Version NPM Downloads/Month NPM Downloads

JSTP / JavaScript Transfer Protocol

JSTP is an RPC protocol and framework which provides two-way asynchronous data transfer with support of multiple parallel non-blocking interactions that is so transparent that an app may not even distinguish between local async functions and remote procedures.

And, as a nice bonus, there's a blazing fast JSON5 implementation bundled in!

This project is bound by a Code of Conduct.

Installation

JSTP works in Node.js and web browsers:

$ npm install --save @metarhia/jstp

Or, alternatively, there is jstp.umd.js UMD bundle.

We also have official client-side implementations for Swift and Java that work effortlessly on iOS and Android 🎉

There is also an interactive CLI provided by this package:

$ npm install -g @metarhia/jstp
$ jstp-cli

Getting Started

Server:

'use strict';

const jstp = require('@metarhia/jstp');

// Application is the core high-level abstraction of the framework. An app
// consists of a number of interfaces, and each interface has its methods.
const app = new jstp.Application('testApp', {
  someService: {
    sayHi(connection, name, callback) {
      callback(null, `Hi, ${name}!`);
    },
  },
});

// Let's create a TCP server for this app. Other available transports are
// WebSocket and Unix domain sockets. One might notice that an array of
// applications is passed the `createServer()`. That's because it can serve
// any number of applications.
const server = jstp.net.createServer([app]);
server.listen(3000, () => {
  console.log('TCP server listening on port 3000 🚀');
});

Client:

'use strict';

const jstp = require('@metarhia/jstp');

// Create a TCP connection to server and connect to the `testApp` application.
// Clients can have applications too for full-duplex RPC,
// but we don't need that in this example. Client is `null` in this example,
// this implies that username and password are both `null`
// here — that is, the protocol-level authentication is not leveraged in this
// example. The next argument is an array of interfaces to inspect and build
// remote proxy objects for. Remaining arguments are for
// net.connect (host and port) and last argument is a callback
// to be called on successful connection or error.
jstp.net.connectAndInspect(
  'testApp',
  null,
  ['someService'],
  3000,
  'localhost',
  handleConnect
);

function handleConnect(error, connection, app) {
  if (error) {
    console.error(`Could not connect to the server: ${error}`);
    return;
  }

  // The `app` object contains remote proxy objects for each interface that has
  // been requested which allow to use remote APIs as regular async functions.
  // Remote proxies are also `EventEmitter`s: they can be used to `.emit()`
  // events to another side of a connection and listen to them using `.on()`.
  app.someService.sayHi('JSTP', (error, message) => {
    if (error) {
      console.error(`Oops, something went wrong: ${error}`);
      return;
    }
    console.log(`Server said "${message}" 😲`);
  });
}

Project Maintainers

Kudos to @tshemsedinov for the initial idea and proof-of-concept implementation. Current project team is:

More Repositories

1

impress

Enterprise application server for Node.js and Metarhia private cloud ⚡
JavaScript
969
star
2

metasync

Asynchronous Programming Library for JavaScript & Node.js
JavaScript
205
star
3

Example

Metarhia application example for Node.js 🟢
JavaScript
198
star
4

noroutine

Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
JavaScript
120
star
5

metautil

Metarhia utilities 🧰
JavaScript
98
star
6

web-locks

Web Locks API 🔒
JavaScript
83
star
7

Docs

Metarhia docs and F.A.Q. 📒
82
star
8

metacom

RPC communication protocol for Metarhia stack 🔌
JavaScript
80
star
9

BestPractice

Metarhia best practice for relative technologies
62
star
10

common

Metarhia Common Library 🗜️
JavaScript
62
star
11

Metarhia

Technology Stack for Highload Applications ⬢
HTML
61
star
12

globalstorage

Distributed Data Warehouse 🌍
JavaScript
60
star
13

swayer

Schema based frontend framework 👀
JavaScript
52
star
14

metaschema

Schema definition and validation 💡
JavaScript
52
star
15

sandboxed-fs

Sandbox wrapper for Node.js File System API 💾
JavaScript
47
star
16

concolor

Colouring template strings using tags with annotations 🎨
JavaScript
44
star
17

do

Simplest way to manage asynchronicity
JavaScript
43
star
18

metarhia.com

Metarhia technology stack web site ⬢
JavaScript
40
star
19

metalog

Metarhia logger 📝
JavaScript
40
star
20

metasql

Metarhia SQL builder and Postgres utilities 🐘
JavaScript
40
star
21

metavm

Script loader with isolated sandboxes for node.js 📦
JavaScript
39
star
22

Contracts

Metarhia core docs and contracts specifications 📒
37
star
23

tickplate

Back-tick template engine for JavaScript 💬
JavaScript
33
star
24

arhaica

Milti-Domain Content Publishing System for Archaic Web
JavaScript
32
star
25

Manifesto

Manifesto of Metarhia Community ⬢
29
star
26

messenger

JavaScript
29
star
27

impress-cli

Impress Application Server Command line interface
JavaScript
28
star
28

console

Constructivism in UI rendering
26
star
29

JSQL

JavaScript Query Language
JavaScript
25
star
30

impress-example

Example application for Impress Application Server
JavaScript
23
star
31

eslint-config-metarhia

ESLint config for Metarhia projects
JavaScript
18
star
32

metatests

Extremely simple to use test framework and runner for Metarhia technology stack 🧪
JavaScript
18
star
33

metawatch

Nested directories watch for node.js 🕵️
JavaScript
14
star
34

metaconfiguration

Metarhia configuration loader 🔧
JavaScript
14
star
35

SummerCamp

Metarhia Summer Camp 2022
12
star
36

metastreams

Readable and Writable Streams with buffering
JavaScript
12
star
37

lowscript

Low-code script engine for Metarhia 📃
JavaScript
11
star
38

Metapay

Metarhia payment subsystem 🪙
11
star
39

sql

Metarhia SQL utilities
JavaScript
11
star
40

metadomain

Metarhia core model: database schemas 💎
JavaScript
10
star
41

metadoc

Metarhia Documentation Generator
JavaScript
10
star
42

metacalc

Spreadsheet calculations for Metarhia 🧮
JavaScript
10
star
43

Template

Metarhia app minimal template 🔵
JavaScript
9
star
44

mdsf

Metarhia Data Serialization Format
C++
9
star
45

Roadmap

Roadmap for new contributors and for technology stack 🛣️
9
star
46

Metalocal

Smart local area, township, housing, city solution 🏘️
9
star
47

jstp-swift

Swift
9
star
48

Accounts

User accounts, contacts, permissions, and authentication subsystem 👥
8
star
49

metamail

Metarhia mail subsystem ✉️
JavaScript
8
star
50

metacom-android

Metacommunicator for Android
Java
8
star
51

metacms

Metarhia CMS
JavaScript
8
star
52

iterator

Efficient and composable iteration
JavaScript
8
star
53

filestorage

JavaScript
8
star
54

protocol

Metarhia Protocol
Shell
8
star
55

tools

Metarhia development tools
JavaScript
7
star
56

Metanet

Communication, messaging, file transfer and content publishing 🔭
7
star
57

console-web

Metarhia web client
JavaScript
7
star
58

MetaTalk

Metarhia application example: chat, file storage, auth
JavaScript
7
star
59

metagram

ERD generator for metaschema
JavaScript
7
star
60

metatests-browser-runner

Browser test runner for metatests ⚙️
JavaScript
7
star
61

eslint-plugin-impress

ESLint plugin for Impress Application Server
JavaScript
6
star
62

xxii

xxii news
JavaScript
6
star
63

metacom-ios

Metacommunicator for iOS
Swift
6
star
64

jstp-java

JSTP implementation in java
Java
5
star
65

metascheduler

Metarhia task scheduler 📅
JavaScript
5
star
66

metaschema-langserver

Metaschema Language Server Protocol
5
star
67

metastorage

Metarhia file storage
JavaScript
5
star
68

metagui

GUI Components for Metarhia technology stack
JavaScript
5
star
69

remark-preset-lint-metarhia

Opinionated remark-lint preset
JavaScript
5
star
70

metacommand

Metarhia command-line interface utilities
JavaScript
5
star
71

mtypes

Common types for Metarhia 🤝
JavaScript
5
star
72

Partners

Metarhia (NodeUA and HowProgrammingWorks) Community Partners
5
star
73

namespace

High stable namespace registry of algorithms, tools, data structures, modules, components, etc.
JavaScript
5
star
74

Infrastructure

Metarhia Common Infrastructure 📦
5
star
75

ExampleWebSite

Example Web Site for metacms
JavaScript
5
star
76

metacode

Development Environment for Metarhia Stack
4
star
77

highcode

High-code is like low-code and no-code, but with higher abstraction 🧑‍💻
JavaScript
4
star
78

prettier-config

Prettier config for Metarhia projects
4
star
79

thread-balancer

Thread load balancer
3
star
80

StopList

Community Technology Stop-list
3
star
81

.github

The first technology stack for Node.js scaled with threads
1
star