7.2.1 • Published 8 years ago

level-http-recorder v7.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

level-http-recorder Build Status stable

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 = require('stack')
var db = require('level-bytewise')('./mydb')
var http = require('http')

var levelHttpRecorder = require('level-http-recorder')(db)

http.createServer(stack(levelHttpRecorder))

modify before a request is persisted

var stack = require('stack')
var db = require('level-bytewise')('./mydb')
var http = require('http')

var levelHttpRecorder = require('level-http-recorder')(db, function (requestData, request) {
    // do stuff to request data
    // DO NOT modify request!
    requestData.myField = 'foo'
})

http.createServer(stack(levelHttpRecorder))

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: request.ip, // if request had an ip property, this will be it
        requestId: [12312312312233,2] // the leveldb key of the request,
        method: request.method,
        httpVersion: request.httpVersion,
        headers: request.headers,
        url: request.url,
        trailers: request.trailers,
        time: Date.utc(),
        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
    }
7.2.1

8 years ago

7.2.0

8 years ago

7.1.0

9 years ago

7.0.0

9 years ago

5.0.0

9 years ago

4.1.0

9 years ago

4.0.2

9 years ago

4.0.1

9 years ago

4.0.0

9 years ago

3.0.0

10 years ago

2.0.4

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago