Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ataraxia-services
Advanced tools
Services with RPC and events for Ataraxia.
This project provides a service layer on top of a Ataraxia network and allows nodes to easily register services and to call methods and receive events on services on other nodes.
npm install ataraxia-services
import { Services } from 'ataraxia-services';
const net = ... // setup network with at least one transport
const services = new Services(net);
services.onAvailable(service => console.log(service.id, 'is now available'));
services.onUnavailable(service => console.log(service.id, 'is no longer available'));
// Start the network
await net.start();
// Start the services on top of the network
await services.start();
// Register a service as a plain object
const handle = services.register({
id: 'service-id',
hello() {
return 'Hello world';
}
});
// Classes can be registered and created
services.register(class Test {
constructor(handle) {
this.handle = handle;
this.id = 'service-id';
}
hello() {
return 'Hello World';
}
})
// Interact with services
const service = services.get('service-id');
if(service) {
console.log('Service found', service);
// Call functions on the service
const reply = await service.hello();
}
ataraxia-services
supports emitting and listening to events. The support for
events is designed to be used via Atvik.
import { Event } from 'atvik';
class TestService {
constructor(handle) {
this.id = 'test';
this.helloEvent = new Event(this);
}
get onHello() {
// This onX method makes the event available on the service
return this.helloEvent.subscribable;
}
sayHello(message) {
// Emit an event
this.helloEvent.emit(message);
// Return a result
return 'Hello ' + message + '!';
}
}
// Register the service
services.register(TestService);
// Get the service either on the same node or another node
const service = services.get('test');
// Listen to the event
const handle = await service.onHello(message => console.log('Service emitted hello event:', message));
// Call the method to emit the event
await service.sayHello('World');
// Unsubscribe from event
await handle.unsubscribe();
FAQs
Services with RPC and events over Ataraxia mesh network
The npm package ataraxia-services receives a total of 7 weekly downloads. As such, ataraxia-services popularity was classified as not popular.
We found that ataraxia-services demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.