metacom

Communication protocol for Metarhia stack with rpc, events, binary streams, memory and db access

Usage no npm install needed!

<script type="module">
  import metacom from 'https://cdn.skypack.dev/metacom';
</script>

README

Metacom Communication Protocol for Metarhia

ci status codacy snyk npm version npm downloads/month npm downloads

Metacom protocol specification: https://github.com/metarhia/Contracts/blob/master/doc/Metacom.md

// Load at frontend
import { Metacom } from './metacom.js';

// Load at backend
const { Metacom } = require('metacom');

// Open connection (both platforms) and make calls
const metacom = Metacom.create('https://domainname.com:8000');
(async () => {
  const { api } = metacom;
  try {
    await metacom.load('auth'); // Load `auth` interface
    await api.auth.status(); // Check session status
  } catch (err) {
    await api.auth.signIn({ login: 'marcus', password: 'marcus' });
  }
  await metacom.load('example'); // Load `example` interface
  const result = api.example.methodName({ arg1, arg2 });
})();