BitSensor Node.js Plugin
Usage
Add bitsensor
to your dependencies.
npm install bitsensor --save
Create a config.json
file.
Run BitSensor inside your handleRequest()
method.
var BitSensor = require('bitsensor/core/bitsensor');var HttpHandler = require('bitsensor/handler/http-handler');var fs = require('fs'); var http = require('http'); // Start BitSensor with the path of the config.json file as argumentvar sensor = new BitSensor(fs.realpathSync('config.json')); function handleRequest(request, response) { // Use the handler for http server sensor.addHandler(new HttpHandler(request, response)); sensor.runHandlers(); sensor.authorize(function () { // DoYaThing }, response);} var server = http.createServer(handleRequest); server.listen(8080, function () { console.log('Server listening on http://localhost:8080');});