
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Connect to (and, if needed, fire up) a daemon with exposed asynchronous API and share or cache data across clients.
Connect to (and, if needed, fire up) a daemon with exposed asynchronous API and share or cache data across clients.
APID fits your needs if you want to split your node.js code to
apid
npm isntall apid --save
var apid = require('apid'), // apid library
server = apid.server; // apid.server instance
// example API
var math = {
sum: function(a, b, callback) {
callback.remote.version(function (err, caller_version) {
callback(null, a + b, '*' + caller_version + '*');
});
}
}
// expose API before starting the service
server.expose({math: math});
// starting server 'my-daemon-name-id'
server.start('my-daemon-name-id', function (err) {
// ready and listening. Outputs are redirected to files in:
// ~/.config/my-daemon-name-id/apid-$UID.[err|out]
console.log('started');
});
var apid = require('apid'), // apid library
client = apid.client('my-daemon-name-id'); // apid client instance
// expose API on the client. This can be called from the daemon.
client.expose('version', function (callback) {
callback(null, '1.0.0');
});
// connect (and fire up daemon if not running yet)
client.connect(__dirname + '/daemon-entry.js', function (err) {
// ready and connected to apid server. Call a remote method:
client.remote.math.sum(1, 3, function (err, sum, caller_version) {
console.log('This should be 4:', sum);
console.log('Caller version returned:', caller_version);
});
});
Returns newly created or existing named client
Connects to APID daemon as a client, fires up the daemon if not running yet
Useful options:
Server instance. Utilize it for creating daemons.
Fires up daemon
Subscribes for "client is connected" event. This happens: - every time a client is connected and has fully exposed its features to the server, and - right before the server sends acknowledge message to client Callback function has exactly one argument: a metafunction that has exactly the same interface as regular callbacks (cb.remote, cb.session) but will do nothing when called itself as cb()
Exposes a function (or functions on an object) to make them available for connecting peers on the .remote object Asynchronous alert:
callback(err[, arg1[, arg2, ...]]);
where err is an Error type or null
or undefined
if there was no error.
Note: available on both client and apid.server instances.Add keys and values to apid.session you want to share. Be careful not to add too much, this will be distributed in connection time. Note:
Container of exposed API on remote peer. See example daemon-entry.js above.
Returns daemon status in a callback. Callback signiture is: (err, pid)
where err
will be null or an Error object (if daemon is not running) and pid
will be null or process ID of the daemon
Ping remote
Trigger remote's console.log() on client
Trigger remote's console.error() on client
node my-client.js --daemon-start
This will exit after daemon is started. E.g. your code will run until the client connects.
node my-client.js --daemon-stop
This will exit after daemon is started. E.g. your code will run until the client connects.
node my-client.js --daemon-kill
This will exit after daemon is started. E.g. your code will run until the client connects.
node my-client.js --daemon-restart
This will NOT exit after (re)starting daemon. E.g. your code will continue running after the status was output.
node my-client.js --daemon-reload
This will NOT exit after (re)loading daemon. E.g. your code will continue running after the status was output.
node my-client.js --daemon-status
This will exit after daemon is started. E.g. your code will run until the client connects.
node my-client.js --daemon-stdout --daemon-stderr
FAQs
Connect to (and, if needed, fire up) a daemon with exposed asynchronous API and share or cache data across clients.
The npm package apid receives a total of 0 weekly downloads. As such, apid popularity was classified as not popular.
We found that apid 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.