npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@no-pro/express-middleware

v1.0.0

Published

node profiling tools - express middleware

Downloads

3

Readme

no-pro express-middleware - express-compatible middleware to profile keyed requests

NPM version

Part of the no-pro mono-repo.

install

npm install @no-pro/express-middleware

quick start

...

const profilingMiddleware = require('@no-pro/express-middleware')

...

const app = express()

...

app.use('*', profilingMiddleware({
  profilingKey: 'my-secret-profiling-key-42',
  writeProfile: '/tmp'
}))

...

The options here indicate that profiles will be written to the /tmp directory, and that only requests with the following header will be profiled:

x-no-pro-profiling-key: my-secret-profiling-key-42

usage

The package exports a function which will return an express middleware function to profile requests to the server.

The exported function takes an object as a parameter, with the following properties:

  • all the options from the runtime startProfiling() function function

  • profilingKey (required)

    A string which will be the "key" that indicates requests should be profiled. This key needs to be sent as the value of the http header x-no-pro-profiling-key when making a request that you'd like to profile.

  • writeProfile (required)

    A string or function which indicates where to write the profile.

    If a string is passed, it will be used as the directory name to write the profile to, with the suggested file name, as described below.

    If a function is passed, it will be invoked with the following arguments:

    • http request object
    • http response object
    • JSON-able profile data
    • suggestedFileName

    The suggested file name is built from the date, request method, and url.

    For example, to write the profile data to the console (not recommended, heh), use:

    writeProfile: function (req, res, profile) { console.log(profile) }
  • profilingKeyHeader

    Rather than using the header x-no-pro-profiling-key to pass the profiling key, you can specify the header with this option.

  • profilingSuggestedNameHeader

    In the http response of a request that has been profiled, a header with the name x-no-pro-suggested-name will be added with the suggested name of the profile. The name of the header can be overridden with this value.

changelog

See the file CHANGELOG.md.

license / contributing / etc

See the root of the no-pro mono-repo.