express-request-capture

Node.js express middleware for capturing HTTP requests and responses

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
express-request-capture
3.0.15 years ago5 years agoMinified + gzip package size for express-request-capture in KB

Readme

Express Request Capture
Node.js express middleware for capturing HTTP requests and responses
styled with prettier Greenkeeper badge Travis codecov Dev Dependencies Donate

API

var requestCapture = require ('express-request-capture')

  • requestCapture ({ channel: string, url?: string })

When using this module with express or connect, simply app.use the module. Request information url, request, response, status, latency, and clientIp, is printed/stored to the specified channel!
var requestCapture = require ('express-request-capture'),
    express = require ('express')

var app = express()

var printAdapter = { channel: 'console|http', url: 'required if channel is either http' };
app.use(requestCapture(printAdapter))

// sample response
{
    url: "https://alert.clearonline.org/api/v1/subscribe",
    method: "POST",
    status: 200,
    latency: 100,
    request: {
        headers: {
            "Content-Type": "application/json"
        },
        body: {
            email: "hello@clearonline.org",
            trigger: "solar energy"
        },
        host: "localhost:3000",
        clientIp: "192.111.1.1"
    },
    response: {
        header: {
            "Date": "2017-06-02T22:29:44.315Z"
        },
        body: {
            message: "Thank you for subscribing, i will send you notes every monday!"
        }
    }
}

Examples

Packaging

  • use of jsnext:main: https://github.com/jsforum/jsforum/issues/5

Resource