JSPM

koa-log-requests

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q66309F
  • License MIT

Log request method, path, status, time spent and body

Package Exports

  • koa-log-requests

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koa-log-requests) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

koa-log-requests

Customizable Koa middleware for logging incoming requests. Outputs method, path, response status, time spent and request body.

Installation

$ npm install koa-log-requests --save

Usage

var koa = require('koa');
var requests = require('koa-log-requests');

var app = koa();

app.use(requests());
app.use(function * (next) {
    this.body = 'Hello World';
    
    yield next;
});

app.listen(3000);

Options

There are few options, that you can customize:

var requests = require('koa-log-requests');

requests.indent = 2; // insert N spaces at the beginning
requests.format = ':method :path status=:status time=:time body=:body'; // format of output
requests.filter = ['password', 'password_confirmation']; // filter out these keys from request body

License

koa-log-requests is released under the MIT license.