A rudimentary middleware / handler that records http requests to a local level db.
Compatible with various web frameworks that use standard middleware interface function (req, res, next) {}
This module expects the given db to support:
- levelup interface
- bytewise key encoding
- json value encoding
normal use:
var stack = var db = './mydb'var http = var levelHttpRecorder = db http
modify before a request is persisted
var stack = var db = './mydb'var http = var levelHttpRecorder = db { // do stuff to request data // DO NOT modify request! requestDatamyField = 'foo'} http
schema
Every recorded request will have the following fields, represented here as the field name: the field name used to populate the value from the request object
var result = ip: requestip // if request had an ip property, this will be it requestId: 123123123122332 // the leveldb key of the request, method: requestmethod httpVersion: requesthttpVersion headers: requestheaders url: requesturl trailers: requesttrailers time: Date query: {} // a parsed query string body: ... // if there is a body to the request and config.writeBody === true || request.writeBody === true - this field will hold the entire body. It is advisable to employ limit restrictions