Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Gallop polls REST APIs at particular intervals to listen for changes.
Gallop is available on the NPM registry.
npm install gallop
var gallop = require('gallop')({
interval: 10
});
// Add a target.
gallop.subscribe('//api-endpoint.provider.com/api', null, function(err, result, httpResponse){
if(err){
return console.error(err);
}
console.log(result);
})
// Start listening.
gallop.start();
Requiring Gallop exposes a Gallop constructor. This object serves as a daemon which listens to requests in the background. Arguments:
options
-- An optional options object with keys:
interval
-- The polling interval in milliseconds. Defaults to 1 minute.var Gallop = require('gallop');
var daemon = new Gallop({
interval: 500
});
A Gallop daemon subscribes to targets, which are composed of a REST API URL, an options object for the request, and a callback that fires whenever the response from that API endpoint changes. Arguments:
url
-- A string endpoint URLoptions
-- An options object for the request -- see documentation for Restler's optionscallback
-- A callback that takes err
, result
, and httpResponse
to be called whenever the data changesdaemon.subscribe('//api-endpoint.provider.com/api', {
method: 'GET',
query: {
api_key: 'some API key',
some_field: 'some data for the field'
// ...
}
}, function(err, result, httpResponse) {
if (err) {
return console.error(err);
}
console.log(result);
});
subscribe
returns a target ID, which can be passed to unsubscribe
to remove the target.
// Save the target ID.
var id = daemon.subscribe( /* ... */ );
// Unsubscribe from the target.
daemon.unsubscribe(id);
The Gallop daemon can start
and stop
; stopping in the middle of the polling cycle will complete the current cycle.
daemon.start();
// Some time later...
daemon.stop();
© 2013 Lehao Zhang. Released under the terms of the MIT license.
FAQs
Polls REST APIs for changes.
We found that gallop 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.