GithubHelp home page GithubHelp logo

miniprofiler / node Goto Github PK

View Code? Open in Web Editor NEW
199.0 18.0 26.0 706 KB

A simple but effective mini-profiler for Node.js websites

Home Page: https://npmjs.org/package/miniprofiler

JavaScript 99.91% Pug 0.09%

node's Introduction

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.

node's People

Contributors

dependabot[bot] avatar gisenberg avatar goenning avatar kevin-montrose avatar maddyblue avatar nickcraver avatar sweatercomeback avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node's Issues

Still active?

Hello,

I'm trying to test miniprofiler for node but there's no documentation and the test_app.js crashes with

TypeError: Object #<Object> has no method 'startProfiling'

Are you still developing/supporting this module?

Regards,

Laurent

can I take over it?

I'm a big fan of MiniProfiler for .Net, it's just awesome!
But now that I'm working with node.js, I'd like to be able to use miniprofiler with it as well.

I saw that miniprofiler-node is kind of dead right now, but I'd like to bring it back to life.

Please take a look at goenning/miniprofiler-node
There is still a lot of work to be done here, specially regarding providers, but that's a good start.

If you do allow me, I'd like to take over it. If that's not an option, I'd break the fork and start a new package, but of course, using miniprofiler's ui and giving MiniProfiler the proper credits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.