|
1 | | -##### `The project is still under development, the API will change! Use with caution. NPM package is currently outdated.` |
2 | | - |
3 | | -# node-miniprofiler |
4 | | - |
5 | | -Node.js implementation of Stack Exchange's MiniProfiler |
6 | | - |
7 | | -[](https://img.shields.io/npm/v/miniprofiler.svg) |
8 | | -[](https://travis-ci.org/MiniProfiler/node) |
9 | | -[](https://coveralls.io/github/MiniProfiler/node?branch=master) |
10 | | - |
11 | | - |
12 | | - |
13 | | -## Installation (via [npm](https://npmjs.org/package/miniprofiler)) |
14 | | - |
15 | | -```bash |
16 | | -$ npm install miniprofiler |
17 | | -``` |
18 | | - |
19 | | -## Usage |
20 | | - |
21 | | -### Simple usage using express.js |
22 | | - |
23 | | -`server.js` |
24 | | - |
25 | | -```javascript |
26 | | -var express = require('express') |
27 | | - , miniprofiler = require('miniprofiler') |
28 | | - , app = express(); |
29 | | - |
30 | | -app.set('view engine', 'pug'); |
31 | | -app.use(miniprofiler.profile()); |
32 | | - |
33 | | -app.get('/', function(req, res) { |
34 | | - req.miniprofiler.step('Step 1', function() { |
35 | | - req.miniprofiler.step('Step 2', function() { |
36 | | - res.render('home'); |
37 | | - }); |
38 | | - }); |
39 | | -}); |
40 | | - |
41 | | -app.listen(8080); |
42 | | -``` |
43 | | - |
44 | | -`home.pug` |
45 | | - |
46 | | -```javascript |
47 | | -doctype html |
48 | | -html |
49 | | - head |
50 | | - title MiniProfiler Node.js Example |
51 | | - body |
52 | | - h1 Home Page |
53 | | - | !{miniprofiler.include()} |
54 | | -``` |
55 | | - |
56 | | -When visiting `localhost:8080`, you should see this. |
57 | | - |
58 | | - |
59 | | - |
60 | | -See [tests/servers/<your web framework>](/tests/servers) for more examples. |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | -# Want to help? |
66 | | - |
67 | | -Things to do: |
68 | | - |
69 | | -- Refactor/Remove TODO comments |
70 | | -- transform test cases into runnable examples (npm run example) |
71 | | -- storing of client timings on first result postback (there's a todo in the `results` function about where to do this) |
72 | | -- document more things |
73 | | -- add providers for pg, mongodb, mysql, redis and more |
| 1 | +##### `The project is still under development, the API will change! Use with caution. NPM package is currently outdated.` |
| 2 | + |
| 3 | +# node-miniprofiler |
| 4 | + |
| 5 | +Node.js implementation of Stack Exchange's MiniProfiler |
| 6 | + |
| 7 | +[](https://img.shields.io/npm/v/miniprofiler.svg) |
| 8 | +[](https://travis-ci.org/MiniProfiler/node) |
| 9 | +[](https://coveralls.io/github/MiniProfiler/node?branch=master) |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Installation (via [npm](https://npmjs.org/package/miniprofiler)) |
| 14 | + |
| 15 | +```bash |
| 16 | +$ npm install miniprofiler |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +### Simple usage using express.js |
| 22 | + |
| 23 | +`server.js` |
| 24 | + |
| 25 | +```javascript |
| 26 | +var express = require('express') |
| 27 | + , miniprofiler = require('miniprofiler') |
| 28 | + , app = express(); |
| 29 | + |
| 30 | +app.set('view engine', 'pug'); |
| 31 | +app.use(miniprofiler.profile()); |
| 32 | + |
| 33 | +app.get('/', function(req, res) { |
| 34 | + req.miniprofiler.step('Step 1', function() { |
| 35 | + req.miniprofiler.step('Step 2', function() { |
| 36 | + res.render('home'); |
| 37 | + }); |
| 38 | + }); |
| 39 | +}); |
| 40 | + |
| 41 | +app.listen(8080); |
| 42 | +``` |
| 43 | + |
| 44 | +`home.pug` |
| 45 | + |
| 46 | +```javascript |
| 47 | +doctype html |
| 48 | +html |
| 49 | + head |
| 50 | + title MiniProfiler Node.js Example |
| 51 | + body |
| 52 | + h1 Home Page |
| 53 | + | !{miniprofiler.include()} |
| 54 | +``` |
| 55 | + |
| 56 | +When visiting `localhost:8080`, you should see this. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +See [tests/servers/<your web framework>](/tests/servers) for more examples. |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +# Want to help? |
| 66 | + |
| 67 | +Things to do: |
| 68 | + |
| 69 | +- Refactor/Remove TODO comments |
| 70 | +- transform test cases into runnable examples (npm run example) |
| 71 | +- storing of client timings on first result postback (there's a todo in the `results` function about where to do this) |
| 72 | +- document more things |
| 73 | +- add providers for pg, mongodb, mysql, redis and more |
0 commit comments