A webhook implementation which extends the concept to HTTP REST API's
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:
In order to successfully run the tests three environment variables are used for setting the port numbers:
For 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.).
httphooks you are able to associate logical units for execution with url paths with a given HTTP verb.
var http = require'http';var HttpHooks = 'httphooks';var hooks = ;// Respond to any incoming requests with a hello world message which includes the url pathhooksget'/*'var request = hookContextrequest;var response = hookContextresponse;hookContextsetResponse200'Content-Type': 'text/html''Welcome to \'' + requesturlpath + '\'... Hello World! :)';done;;var server = httpcreateServerhooksdispatchrequest: request response: response;;serverlisten8080;