@byu-oit/express-profiler-middleware
v0.1.1
Published
An express middleware function for profiling client requests
Downloads
1
Readme
Express Profiler Middleware
An Express middleware function for profiling client requests using the v8 profiler (See v8-profiler-next).
Usage Example
const express = require('express')
const profiler = require('@byu-oit/express-profiler-middleware')
const app = express()
app.use(profiler.middleware((req, profile) => {
const fileName = `${Date.now().toString()}-${req.method}${req.path.split('/').join('-')}.cpuprofile`
profile.export((error, result) => fs.writeFileSync(fileName, result))
}))
app.get('/xhealth', (req, res) => {
setTimeout(() => res.sendStatus(200), 250)
})
let port = process.env.PORT || 8080
app.listen(port, () => console.log(`Server listening on port ${port}`))