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

@betit/orion

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@betit/orion - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

examples/client.js

@@ -5,5 +5,5 @@ const orion = require('..');

client.add({ a: 3, b: 2 }, (res) => {
console.log(res);
client.add({ a: 3, b: 2 }, (err, res) => {
console.log(err, res);
client.close();
});

@@ -7,5 +7,5 @@ const orion = require('..');

console.log(message);
process.exit();
broker.close();
});
broker.publish('test', 'hello');

@@ -11,3 +11,3 @@ const orion = require('..');

console.log(res);
process.exit();
transport.close();
});

@@ -5,4 +5,4 @@ const orion = require('..');

service.handle('add', (request, reply) => {
reply(request.params.a + request.params.b);
service.handle('add', (args, reply) => {
reply(null, args.a + args.b);
});

@@ -9,0 +9,0 @@

@@ -1,2 +0,2 @@

import { ClientOptions } from '../types/interfaces';
import { ClientServiceOptions } from '../types/interfaces';
/**

@@ -10,2 +10,2 @@ * Client proxy

*/
export default function (serviceName: string, options?: ClientOptions): void;
export default function (serviceName: string, options?: ClientServiceOptions): void;

@@ -46,13 +46,11 @@ "use strict";

* @param {string} method
* @param {any} params
* @param {any} payload
* @param {Function} callback
*/
call(method, params, callback) {
call(method, payload, callback) {
let topic = `${this.serviceName}:${method}`;
let req = this.codec.encode({
params: params
});
this.transport.request(topic, req, res => {
let response = utils_1.safeDecode(this.codec, res);
callback(response);
let request = this.codec.encode(payload);
this.transport.request(topic, request, response => {
let res = utils_1.safeDecode(this.codec, response);
callback(res.err, res.body);
}, { max: 1 });

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

@@ -5,4 +5,5 @@ /**

export default class Json {
name: string;
encode(data: any): string;
decode(data: any): any;
}

@@ -6,2 +6,5 @@ "use strict";

class Json {
constructor() {
this.name = 'Json';
}
encode(data) {

@@ -8,0 +11,0 @@ return JSON.stringify(data);

@@ -6,2 +6,3 @@ /**

export default class MsgPack {
name: string;
isBinary: boolean;

@@ -8,0 +9,0 @@ encode(data: any): any;

@@ -9,2 +9,3 @@ "use strict";

constructor() {
this.name = 'MsgPack';
this.isBinary = true;

@@ -11,0 +12,0 @@ }

@@ -1,2 +0,2 @@

import { ServiceOptions } from '../types/interfaces';
import { ClientServiceOptions } from '../types/interfaces';
/**

@@ -14,3 +14,3 @@ * Service

*/
constructor(name: string, options?: ServiceOptions);
constructor(name: string, options?: ClientServiceOptions);
/**

@@ -17,0 +17,0 @@ * Ready callback

@@ -33,7 +33,10 @@ "use strict";

let topic = `${this.name}:${method}`;
this.transport.response(topic, (message, reply) => {
let req = utils_1.safeDecode(this.codec, message);
callback(req, msg => {
let res = this.codec.encode(msg);
reply(res);
this.transport.response(topic, (request, reply) => {
let payload = utils_1.safeDecode(this.codec, request);
callback(payload, (err, res) => {
let response = this.codec.encode({
err: err,
body: res
});
reply(response);
});

@@ -40,0 +43,0 @@ }, { queue: this.name });

export interface Codec {
name: string;
isBinary?: boolean;
encode(data: any): any;
decode(data: any): any;
isBinary?: boolean;
}

@@ -26,3 +27,3 @@ export interface BrokerOptions {

}
export interface ServiceOptions {
export interface ClientServiceOptions {
codec?: Codec;

@@ -32,12 +33,7 @@ transport?: Transport;

export interface Request {
params?: any;
body?: any;
}
export interface Reply {
(res: Response): any;
}
export interface Response {
err: Error;
body?: any;
}
export interface ClientOptions {
codec?: Codec;
transport?: Transport;
}

@@ -6,2 +6,2 @@ import { Codec } from '../types/interfaces';

*/
export declare function safeDecode<T>(codec: Codec, message: any): any;
export declare function safeDecode(codec: Codec, message: any): any;
{
"name": "@betit/orion",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pluggable microservice framework",

@@ -18,3 +18,4 @@ "license": "MIT",

"docs": "jsdoc -c jsdoc.json",
"ghpage": "gh-pages -d .docs"
"ghpage": "gh-pages -d .docs",
"bump": "npm version patch && git push --follow-tags && npm publish"
},

@@ -21,0 +22,0 @@ "dependencies": {

@@ -26,8 +26,8 @@ # Orion

```
import { Service } from 'orion';
const orion = require('@betit/orion');
const service = new Service('calc');
const service = new orion.Service('calc');
service.handle('add', (request, reply) => {
reply(request.params.a + request.params.b);
service.handle('add', (args, reply) => {
reply(null, args.a + args.b);
});

@@ -39,8 +39,8 @@ ```

```
import { Client } from 'orion';
const orion = require('@betit/orion');
const client = new Client('calc');
const client = new orion.Client('calc');
client.add({ a: 3, b: 2 }, (res) => {
console.log(res);
client.add({ a: 3, b: 2 }, (err, res) => {
console.log(err, res);
client.close();

@@ -47,0 +47,0 @@ });

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