Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exorelay

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exorelay

Communication relay between JavaScript code bases and the Exosphere environment

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Exosphere Communication Relay for JavaScript

Communication relay between JavaScript code bases and the Exosphere environment

Circle CI

This library allows you to add Exosphere communication to any Node.js codebase. It is intended to be used in your web or API server. If you want to write a micro-service in Node, please use ExoService-JS, which uses this library internally.

Add an ExoRelay to your application

Each code base should have only one ExoRelay instance.

ExoRelay = require 'exorelay'

exoRelay = new ExoRelay()
exoRelay.listen()

More details and how to customize the port is described in the spec.

Handle incoming commands

Register a handler for incoming commands:

exoRelay.registerHandler 'hello', (name) ->
  console.log "Hello #{name}"

More details on how to define command listeners are here. If you are implementing services, you want to send outgoing replies to incoming commands:

exoRelay.registerHandler 'users.create', (userData, {reply}) ->
  # on this line we would create a user database record with the attributes given in userData
  reply 'users.created', id: 456, name: userData.name

More details and a working example of how to send replies is here.

Send outgoing commands

Send a command to Exosphere:

exoRelay.send 'hello', name: 'world'

Sending a command is fire-and-forget, i.e. you don't have to wait for the sending process to finish before you can do the next thing. More details on how to send various data are here.

You can handle the incoming replies to your outgoing commands:

exoRelay.send 'users.create', name: 'Will Riker', (createdUser) ->
  print "created user #{createdUser.id}"

More examples for handling incoming replies are here. Command handlers also provide a shortcut to send commands:

exoRelay.registerHandler 'users.create', (userData, {send, reply}) ->
  send 'passwords.encrypt' userData.password, (encryptedPassword) ->
    userData.encryptedPassword = encryptedPassword
    # on this line we would create a user database record with the attributes given in userData
    reply 'users.created', id: 456, name: userData.name

More details and a working example of how to send commands from within command handlers is here.

Error handling

ExoRelay emits error events when issues arise. Subscribe to them!

exoRelay.on 'error', (err) -> # examine, print, or log the error here

FAQs

Package last updated on 02 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc