@byu-oit/express-profiler-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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}`))

/@byu-oit/express-profiler-middleware/

    Package Sidebar

    Install

    npm i @byu-oit/express-profiler-middleware

    Weekly Downloads

    4

    Version

    0.1.1

    License

    Apache-2.0

    Unpacked Size

    15.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • mjweather
    • yoshutch
    • lehinpm
    • oscea
    • stuft2
    • mhailstone
    • arasmus8
    • garygsc
    • martingarn
    • snelg
    • byu-oit-bot