JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q21167F
  • License MIT

Link your nodes simple without the need for queues and intermediate servers!

Package Exports

  • @coryfoundation/translink
  • @coryfoundation/translink/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@coryfoundation/translink) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

translink

A high-level API for connecting nodes together using P2P and DHT technologies without using queues (NATS/RabbitMQ/Kafka/etc.) and intermediate servers. Just connect.

All messages are encrypted with end-to-end encryption. (more: http://hypercore-protocol.org)

Using Hyperswarm

Installation

npm install @coryfoundation/translink

Usage

Join to network

import Translink from '@coryfoundation/translink'
const bridge = new Translink({ namespace: 'my-simple-namespace' })

// Subscriptions, events, gets, ...

await bridge.connect()

Subscribe to event

bridge.subscribe('my.event', async (payload) => {
  // Something to do
})

Subscribe to request

bridge.subscribeReq('my.request', async (payload) => {
  // Something to do
  return { something: 'result' }
})

Emit event

bridge.emit('my.event', { something: 'data' })

Make request

bridge.get('my.request', { something: 'data' })
.then((result) => {
  // Something to do
}).catch((error) => {
  console.error('Error', error)
})

Replic nodes

You can duplicate nodes with the same subscriptions an infinite number of times. Translink will send a message to a random available node.

License

MIT