New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bograch

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bograch - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

bograch-0.0.7.tgz

8

lib/bograch.js

@@ -22,4 +22,4 @@ 'use strict';

this[name + 'Client'] = function (options) {
var client = new Client(transporter, options);
this[name + 'Client'] = function (options, cb) {
var client = new Client(transporter, options, cb);
return client;

@@ -36,3 +36,3 @@ };

Bograch.prototype.client = function (name, options) {
Bograch.prototype.client = function (name, options, cb) {
if (!name || typeof name !== 'string') {

@@ -44,3 +44,3 @@ throw new TypeError('Can\'t get a Bograch client w/o a name');

}
var client = new Client(this._transporters[name], options);
var client = new Client(this._transporters[name], options, cb);
return client;

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

@@ -9,3 +9,3 @@ 'use strict';

}
options = options || {};

@@ -18,6 +18,14 @@ if (!options.name) {

this._name = options.name;
if (typeof cb === 'function') {
this.call('methodList', cb);
}
this.methods = {};
cb = cb || function () {};
this.call('methodList', function (err, methods) {
if (err) {
return cb(err);
}
this.register(methods);
return cb(null, this);
}.bind(this));
}

@@ -49,4 +57,4 @@

methods.forEach(function (method) {
if (typeof this[method] === 'undefined') {
this[method] = function (params, cb) {
if (typeof this.methods[method] === 'undefined') {
this.methods[method] = function (params, cb) {
this.call(method, params, cb);

@@ -53,0 +61,0 @@ }.bind(this);

@@ -26,3 +26,3 @@ 'use strict';

cb(null, this._methods);
});
}.bind(this));
};

@@ -29,0 +29,0 @@

{
"name": "bograch",
"version": "0.0.6",
"version": "0.0.7",
"description": "A communication gateway for NodeJS microservices.",

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

@@ -43,3 +43,3 @@ 'use strict';

it('should thrown error if no transporter name was passed', function () {
it('should throw error if no transporter name was passed', function () {
expect(function () {

@@ -58,3 +58,4 @@ bo.client();

bo.use('foo', {
name: 'foo'
name: 'foo',
call: function () {}
});

@@ -70,3 +71,3 @@ expect(bo.client('foo', { name: 'test' })).not.to.be.a('null');

it('should thrown error if no transporter name was passed', function () {
it('should throw error if no transporter name was passed', function () {
expect(function () {

@@ -73,0 +74,0 @@ bo.server();

@@ -5,7 +5,7 @@ 'use strict';

var expect = require('chai').expect;
var TransporterMock = require('./transporter-mock');
var bo = require('../lib');
var noop = function () {};
var transporter = {
call: noop
};
var transporter = new TransporterMock();
var boClient = new Client(transporter, {

@@ -15,28 +15,64 @@ name: 'test'

describe('Bograch client call', function () {
it('should throw an error if no parameters were passed', function () {
expect(function () {
boClient.call();
}).to.throw(TypeError, 'Bograch.on requires a message');
});
describe('Bograch client', function () {
describe('call', function () {
it('should throw an error if no parameters were passed', function () {
expect(function () {
boClient.call();
}).to.throw(TypeError, 'Bograch.on requires a message');
});
it('should throw an error if the third parameter is not a function', function () {
expect(function () {
boClient.call('foo', null, 4234);
}).to.throw(TypeError, 'Bograch.call has an invalid callback function');
});
it('should throw an error if the third parameter is not a function', function () {
expect(function () {
boClient.call('foo', null, 4234);
}).to.throw(TypeError, 'Bograch.call has an invalid callback function');
});
it('should not throw an exception if the second parameter is a callback function', function () {
expect(function () {
boClient.call('foo', noop);
}).not.to.throw(Error);
});
it('should not throw an exception if the second parameter is a callback function', function () {
expect(function () {
boClient.call('foo', noop);
}).not.to.throw(Error);
});
it('should not throw an exception if the third parameter is a callback function', function () {
expect(function () {
boClient.call('foo', {
a: 34
}, noop);
}).not.to.throw(Error);
it('should not throw an exception if the third parameter is a callback function', function () {
expect(function () {
boClient.call('foo', {
a: 34
}, noop);
}).not.to.throw(Error);
});
});
describe('register', function () {
it('should register one method', function () {
boClient.register('foo1');
expect(typeof boClient.methods.foo1).to.be.equal('function');
});
it('should register several methods', function () {
boClient.register(['foo2', 'foo3']);
expect(typeof boClient.methods.foo2).to.be.equal('function');
expect(typeof boClient.methods.foo3).to.be.equal('function');
});
});
describe('proxy', function () {
it('returned by the server', function (done) {
bo.use(transporter);
var server = bo.server('mock', {
name: 'proxy'
});
server.addMethods({
bar: function () {},
baz: function () {},
qux: function () {}
});
bo.client('mock', {name: 'proxy'}, function (err, client) {
expect(typeof client.methods.bar).to.be.equal('function');
expect(typeof client.methods.baz).to.be.equal('function');
expect(typeof client.methods.qux).to.be.equal('function');
done();
});
});
});
});

@@ -5,7 +5,6 @@ 'use strict';

var expect = require('chai').expect;
var TransporterMock = require('./transporter-mock');
var noop = function () {};
var transporter = {
on: noop
};
var transporter = new TransporterMock();
var boServer = new Server(transporter, {

@@ -12,0 +11,0 @@ name: 'test'

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