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

miniprofiler

v1.2.3

Published

A simple but effective mini-profiler.

Downloads

112

Readme

MiniProfiler for Node.js

Node.js implementation of Stack Exchange's MiniProfiler

NPM Build Coverage Dependencies devDependencies

Demonstration

Visit http://miniprofiler-demo.herokuapp.com for a live demonstration.

Installation

$ npm install miniprofiler

You can hook up your application with any of the following packages are available on npm:

| Name | About | Version | |-----------|-----------|-----------| | miniprofiler-http | Profile http(s) requests | NPM | | miniprofiler-pg | Profile pg queries | NPM | | miniprofiler-redis| Profile redis calls | NPM |

Usage

Simple usage with express.js

server.js

var express = require('express')
  , miniprofiler = require('miniprofiler')
  , app = express();

app.set('view engine', 'pug');
app.use(miniprofiler.express());

app.get('/', function(req, res) {
  req.miniprofiler.step('Step 1', function() {
    req.miniprofiler.step('Step 2', function() {
      res.render('index');
    });
  });
});

app.listen(8080);

index.pug

doctype html
html
  head
    title MiniProfiler Node.js Example
  body
    h1 Home Page
    | !{miniprofiler.include()}

When visiting localhost:8080, you should see this.

API

miniprofiler.{framework}([options])

Replace {framework} with koa, express or hapi.

This function returns a framework specific middleware that is responsible for initializing MiniProfiler on each request.

options object properties

| Property | Default | Description | |-----------|-----------|-------------| | enable | Always returns true | function(req, res) => boolean; this function is used to determine if the profiler should be enabled for the current request | | authorize | Always returns true | function(req, res) => boolean; this function is used to determine if the current request should be able to see the profiling results |

miniprofiler.{framework}.for([provider])

provider is a call for any of the supported providers listed here.

miniprofiler.configure([options])

options object properties

| Property | Default | Description | |-----------|-----------|-------------| | storage | InMemoryStorage({ max: 100, maxAge: 1000 * 60 * 60 }) | InMemoryStorage or RedisStorage; used to store or fetch a string JSON blob of profiling information | | ignoredPaths | [ ] | string array ; any request whose url property is in ignoredPaths will not be profiled | | trivialDurationThresholdMilliseconds | 2.5 | double ; any step lasting longer than this will be considered trivial, and hidden by default | | popupShowTimeWithChildren | false | boolean ; whether or not to include the "time with children" column | | popupRenderPosition | left | 'left', 'right', 'bottomLeft' or 'bottomRight' ; which side of the screen to display timings on |

options.storage examples

InMemoryStorage

miniprofiler.configure({
  storage: miniprofiler.storage.InMemoryStorage({ lruCacheOptions });
})

Refer to lru-cache documentation for lruCacheOptions.

RedisStorage

miniprofiler.configure({
  storage: miniprofiler.storage.RedisStorage(client);
})

Where client is an instance of redis.createClient.