Comparing version 0.0.9 to 0.0.10
@@ -64,9 +64,2 @@ 'use strict'; | ||
if (methodName == 'methodList') { | ||
console.log('---||---'); | ||
console.log(arguments); | ||
console.log(args); | ||
console.log(cb); | ||
} | ||
var publicMethodName = createPublicMethodName(this._name, methodName); | ||
@@ -83,3 +76,3 @@ this._transporter.call(publicMethodName, args, cb); | ||
this.methods[method] = function () { | ||
var args = [method].concat(arguments); | ||
var args = [method].concat(Array.prototype.slice.call(arguments)); | ||
this.call.apply(this, args); | ||
@@ -86,0 +79,0 @@ }.bind(this); |
@@ -43,3 +43,3 @@ 'use strict'; | ||
this._transporter.on(publicMethodName, function (args, cb) { | ||
args.push(cb); | ||
args.push(cb || function () {}); | ||
method.apply({}, args); | ||
@@ -46,0 +46,0 @@ }); |
{ | ||
"name": "bograch", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "A communication gateway for NodeJS microservices.", | ||
@@ -10,2 +10,3 @@ "main": "./lib", | ||
"keywords": [ | ||
"bograch", | ||
"microservice", | ||
@@ -16,2 +17,6 @@ "node", | ||
"author": "Zoltan Kochan", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/zkochan/bograch.git" | ||
}, | ||
"license": "MIT", | ||
@@ -18,0 +23,0 @@ "devDependencies": { |
@@ -64,2 +64,20 @@ 'use strict'; | ||
describe('method', function () { | ||
it('should pass argumets to transporter', function (done) { | ||
boClient.register(['fooBar']); | ||
transporter._onCall.push(function (method, args, cb) { | ||
expect(method).to.be.equal('test.fooBar'); | ||
expect(args.length).to.be.equal(3); | ||
expect(args[0]).to.be.equal(1); | ||
expect(args[1]).to.be.equal(2); | ||
expect(args[2]).to.be.equal(3); | ||
expect(typeof cb).to.be.equal('function'); | ||
done(); | ||
transporter._onCall.pop(); | ||
}); | ||
boClient.methods.fooBar(1, 2, 3, noop); | ||
}); | ||
}); | ||
describe('proxy', function () { | ||
@@ -66,0 +84,0 @@ it('returned by the server', function (done) { |
'use strict'; | ||
var Server = require('../lib/server'); | ||
var Client = require('../lib/client'); | ||
var expect = require('chai').expect; | ||
@@ -37,2 +38,18 @@ var TransporterMock = require('./transporter-mock'); | ||
}); | ||
}); | ||
describe('Bograch client/server communication', function () { | ||
var boClient = new Client(transporter, { | ||
name: 'test' | ||
}); | ||
it('should pass all the arguments', function (done) { | ||
boServer.on('sum', function (a, b, cb) { | ||
expect(a).to.be.equal(32); | ||
expect(b).to.be.equal(54); | ||
expect(typeof cb).to.be.equal('function'); | ||
done(); | ||
}); | ||
boClient.call('sum', 32, 54); | ||
}); | ||
}); |
@@ -6,2 +6,3 @@ 'use strict'; | ||
this._methods = {}; | ||
this._onCall = []; | ||
} | ||
@@ -14,2 +15,5 @@ | ||
Transporter.prototype.call = function (method, args, cb) { | ||
this._onCall.forEach(function (fn) { | ||
fn(method, args, cb); | ||
}); | ||
if (this._methods[method]) { | ||
@@ -16,0 +20,0 @@ this._methods[method](args, cb); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
2957747
25
425
0
10