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 - npm Package Compare versions

Comparing version 0.5.4 to 0.6.0

4

lib/exorelay.js

@@ -20,2 +20,3 @@ // Generated by LiveScript 1.4.0

this._onIncomingCommand = bind$(this, '_onIncomingCommand', prototype);
this.send = bind$(this, 'send', prototype);
this.commandHandler = new HandlerManager();

@@ -54,3 +55,4 @@ this.commandSender = new CommandSender({

return this.commandHandler.handleRequest(requestData, {
reply: this.commandSender.replyMethodFor(requestData.requestId)
reply: this.commandSender.replyMethodFor(requestData.requestId),
send: this.send
});

@@ -57,0 +59,0 @@ };

{
"name": "exorelay",
"version": "0.5.4",
"version": "0.6.0",
"description": "Communication relay between JavaScript code bases and the Exosphere environment",

@@ -5,0 +5,0 @@ "main": "lib/exorelay.js",

@@ -28,2 +28,24 @@ # Exosphere Communication Relay for JavaScript

## Handle incoming commands
Register a handler for incoming commands:
```coffeescript
exoRelay.registerHandler 'hello', (name) ->
console.log "Hello #{name}"
```
More details on how to define command listeners are [here](features/receiving-commands.feature).
If you are implementing services, you want to send outgoing replies to incoming commands:
```coffeescript
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](features/outgoing-replies.feature).
## Send outgoing commands

@@ -49,22 +71,12 @@

More examples for handling incoming replies are [here](features/incoming-replies.feature).
Command handlers also provide a shortcut to send commands:
## Handle incoming commands
Register a handler for incoming commands:
```coffeescript
exoRelay.registerHandler 'hello', (name) ->
console.log "Hello #{name}"
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 on how to define command listeners are [here](features/receiving-commands.feature).
If you are implementing services, you want to send outgoing replies to incoming commands:
```coffeescript
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](features/outgoing-replies.feature).
More details and a working example of how to send commands from within command handlers is [here](features/sending-from-commands.feature).
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