express-middleware-elapsedtime
v0.0.3
Published
record express each middleware elapsed time
Downloads
3
Readme
express-middleware-elapsedtime
Record each express middleware elapsed time.
Install
npm i --save express-middleware-elapsedtime
Usage
var express = require('express')
var app = express()
var expressMiddlewareElapsedtime = require('express-middleware-elapsedtime')
// it's truly recommend enable this middleware only in developing envrionment
if (process.env.NODE_ENV !== 'production') {
app.use(expressMiddlewareElapsedtime())
}
API
var expressMiddlewareElapsedtime = require('express-middleware-elapsedtime')
expressMiddlewareElapsedtime(options)
Options
Options for this middleware.
key
The key for data saved, defaults to _elapsedtimes
.
hanlder (err, req, res)
When a request done, this handler will called.
All middleware elapsed time will save at req._elapsedtimes
by default.
app.use(expressMiddlewareElapsedtime({
key: 'yourCustomkey',
hanlder: function (err, req, res) {
console.log(req.yourCustomkey)
}
}))