
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
In this world of internet of things, we have realized that while there are multiple frameworks, protocols and standards that allow you to intercommunicate between different devices none is more prevalent than the actual ones exposed by and defined through the web. For this reason, this module has the intent of standardizing using HTTP, REST and web sockets with the intent to facilitate connecting logic and data while maintaining its distribution and facilities.
httphooks is a node HTTP pub-sub architecture that allows you to associate an incoming HTTP request to a single/multiple dependent/independent user defined operations. These operations work in a loosely coupled manner such that together, with a well defined execution model, each collaborate in order to deliver a result. httphooks extends the webhooks model to the primary REST HTTP verbs and formalizes request/response, inter-communication and signaling using HTTP as the communication standard.
While there are existing and similar modules (a.k.a middleware), we have a pretty interesting architecture, model and set of features that are not present in others and which allow you to streamline your development. Don't be shy and take a look at our documentation, you just might be pleasantly surprised...
npm install httphooks
The test suite can be invoked from the command line like this:
npm test
In order to successfully run the tests three environment variables are used for setting the port numbers: PORT, PORT1 and PORT2.
PORT and PORT1 default to 8080PORT2 defaults to 8081For now, if you want to use different port numbers, you'll have to modify the values in the ./tests/runTests.js file. When time permits we'll change this so it can be done in some other manner (i.e. via a JSON file, command-line options, etc.).
With httphooks you are able to associate logical units for execution with url paths with a given HTTP verb.
var http = require('http');
var HttpHooks = new require('httphooks');
var hooks = new HttpHooks();
// Respond to any incoming requests with a hello world message which includes the url path
hooks.get('/*', function (hookContext, done) {
var request = hookContext.request;
var response = hookContext.response;
hookContext.setResponse(
200,
{ 'Content-Type': 'text/html' },
'Welcome to \'' + request.url.path + '\'... Hello World! :)');
done();
});
var server = http.createServer(function (request, response) {
hooks.dispatch({request: request, response: response});
});
server.listen(8080);
FAQs
A webhook implementation which extends the concept to HTTP REST API's
We found that httphooks 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.