Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Communication relay between JavaScript code bases and the Exosphere environment
Communication relay between JavaScript code bases and the Exosphere environment
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, or with legacy Node code bases. If you want to write a new micro-service in Node, please use ExoService-JS, which uses this library internally.
Each code base should have only one ExoRelay instance.
ExoRelay = require 'exorelay'
exoRelay = new ExoRelay exocomPort: <port>, serviceName: <name of the service using ExoRelay>
exoRelay.on 'online', (port) -> # yay, we are online!
exoRelay.on 'error', (err) -> # examine, print, or log the error here
exoRelay.listen 4000
More details and how to customize the port is described in the spec.
ExoRelay instances are EventEmitters. They emit the following events to signal state changes:
online | The instance is completely online now. Provides the port it listens on. |
---|---|
offline | The instance is offline now. |
error | An error has occurred. The instance is in an invalid state, your application should crash. |
Let's say we build a service that greets users. Here is how to register a handler for incoming "hello" messages:
exoRelay.registerHandler 'hello', (name) -> console.log "hello #{name}!"
More details on how to define message listeners are here.
Send a message to Exosphere:
exoRelay.send 'hello', name: 'world'
Sending a message 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.
If you are implementing services, you want to send outgoing replies to incoming messages:
exoRelay.registerHandler 'user.create', (userData, {reply}) ->
# on this line we would save userData in the database
reply 'user.created', id: 456, name: userData.name
More details and a working example of how to send replies is here.
If a message you send expects a reply, you can provide the handler for it right when you send it:
exoRelay.send 'users.create', name: 'Will Riker', (createdUser) ->
console.log "the remove service has finished creating user #{createdUser.id}"
More examples for handling incoming replies are here.
See our developer guidelines
FAQs
Communication relay between JavaScript code bases and the Exosphere environment
The npm package exorelay receives a total of 1 weekly downloads. As such, exorelay popularity was classified as not popular.
We found that exorelay demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.