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
.
handler (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',
handler: function (err, req, res) {
console.log(req.yourCustomkey)
}
}))