New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

procnet

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

procnet

A tool for service oriented architecture or dependency injection.

latest
Source
npmnpm
Version
1.2.6
Version published
Weekly downloads
2
-80%
Maintainers
1
Weekly downloads
 
Created
Source

Procnet build

A remote provider built for use with pogostick (although you could use a different rpc library).

Define Services

Seperate network code from your service definition.

// For example a `math` service
module.exports = procnet.service(function() {
	return {
		add: function(a, b) {
			return a + b;
		},
		multiply: function(a, b) {
			return a * b;
		}
	}
});

Compose Services

// An example `rectangle` service.
module.exports = procnet.service(['math'], function(math) {
	return {
		surface: function(h, w) {
			return math.multiply(h, w);
		}
	};
});

Unit Test Services

One of the benefit of seperating your logic this way is the way it permits you to unit test your services, mocking dependencies.

// You can pick any promise library you want, just need to provide a factory function.
var mock = procnet.mocker(promiseFactory);
var mocked = mock({ 
	math: {
		// Our fake multiply always returns 1 instead
		multiply: function() { return 1; }
	} 
}, rectangle);

mocked
	.surface(2, 2)
	.then(function(r) {
		assert.equal(r, 1);
	});

Read More

  • API Docs
  • Tests

Keywords

rpc

FAQs

Package last updated on 03 Apr 2016

Did you know?

Socket

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.

Install

Related posts