express-request-capture
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

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

Resource

/express-request-capture/

    Package Sidebar

    Install

    npm i express-request-capture

    Weekly Downloads

    62

    Version

    3.0.1

    License

    MIT

    Last publish

    Collaborators

    • nshimiye