The server side request handler for digger
A very simple middleware chain for plain rpc requests
$ npm install digger-warehouse --save
The warehouse is a function through which you pass an object (packet), a callback (responder) and a next (classic middleware style).
An example of a basic warehouse setup:
var Warehouse = require'digger-warehouse';var warehouse = Warehouse;// middleware means we can augment the request and pass it down the chainwarehouseusereqiwashere = 23;warehouseusereplynull 'I was here: ' + reqiwashere');})
To call this - it is just a case of calling the warehouse function with a request:
warehousevalue:20console.logresult;// I was here: 23
A warehouse can be used with plain old packets but it can also simulate REST requests and match the url and method.
var warehouse = Warehouse;// only requests with a url field of '/api/v1' will run this functionwarehouseuse'/api/v1'// only requests that are posted here will be run - params are extractedwarehousepost'/api/v1/:id'replynull 'posted to ' + reqparamsid;