-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
beta version of instrumenting render steps for express, hapi, koa
- Loading branch information
Showing
11 changed files
with
190 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,53 @@ | ||
{ | ||
"name": "miniprofiler", | ||
"version": "0.2.4", | ||
"description": "A simple but effective mini-profiler.", | ||
"main": "lib/miniprofiler.js", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "mocha tests/ -c", | ||
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- tests/ -R spec", | ||
"check-coverage": "istanbul check-coverage --statements 95 --branches 95 --functions 95 --lines 95", | ||
"update-coveralls": "cat coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MiniProfiler/node.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/MiniProfiler/node/issues" | ||
}, | ||
"author": "Guilherme Oenning <oenning.ti@gmail.com> (http://goenning.net/)", | ||
"contributors": [ | ||
"Matt Jibson <matt.jibson@gmail.com> (https://mattjibson.com/)", | ||
"Kevin Montrose" | ||
], | ||
"license": "Apache-2.0", | ||
"readmeFilename": "README.md", | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"node-uuid": "^1.4.7", | ||
"underscore": "^1.8.3" | ||
}, | ||
"tags": [ | ||
"profiler", | ||
"performance", | ||
"profiling", | ||
"timing" | ||
], | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.9", | ||
"eslint": "^2.11.1", | ||
"express": "^4.13.4", | ||
"hapi": "^13.4.1", | ||
"istanbul": "^0.4.3", | ||
"koa": "^1.2.0", | ||
"koa-route": "^2.4.2", | ||
"mocha": "^2.5.3", | ||
"pug": "^2.0.0-alpha7", | ||
"request": "^2.72.0" | ||
} | ||
} | ||
{ | ||
"name": "miniprofiler", | ||
"version": "0.2.5", | ||
"description": "A simple but effective mini-profiler.", | ||
"main": "lib/miniprofiler.js", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "mocha tests/ -c", | ||
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- tests/ -R spec", | ||
"check-coverage": "istanbul check-coverage --statements 95 --branches 95 --functions 95 --lines 95", | ||
"update-coveralls": "cat coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MiniProfiler/node.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/MiniProfiler/node/issues" | ||
}, | ||
"author": "Guilherme Oenning <oenning.ti@gmail.com> (http://goenning.net/)", | ||
"contributors": [ | ||
"Matt Jibson <matt.jibson@gmail.com> (https://mattjibson.com/)", | ||
"Kevin Montrose" | ||
], | ||
"license": "Apache-2.0", | ||
"readmeFilename": "README.md", | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"node-uuid": "^1.4.7", | ||
"underscore": "^1.8.3" | ||
}, | ||
"tags": [ | ||
"profiler", | ||
"performance", | ||
"profiling", | ||
"timing" | ||
], | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.9", | ||
"eslint": "^2.11.1", | ||
"express": "^4.13.4", | ||
"hapi": "^13.4.1", | ||
"istanbul": "^0.4.3", | ||
"koa": "^1.2.0", | ||
"koa-route": "^2.4.2", | ||
"koa-views": "^4.1.0", | ||
"mocha": "^2.5.3", | ||
"pug": "^2.0.0-beta2", | ||
"request": "^2.72.0", | ||
"vision": "^4.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
|
||
module.exports = function(server) { | ||
|
||
describe('Render Tests', function() { | ||
before(server.setUp.bind(null, 'render')); | ||
after(server.tearDown); | ||
|
||
it('Should add Render step', function(done) { | ||
server.get('/', (err, response) => { | ||
var ids = JSON.parse(response.headers['x-miniprofiler-ids']); | ||
expect(ids).to.have.lengthOf(1); | ||
|
||
server.post('/mini-profiler-resources/results', { id: ids[0], popup: 1 }, (err, response, body) => { | ||
var result = JSON.parse(body); | ||
expect(result.Id).to.equal(ids[0]); | ||
expect(result.Name).to.equal('/'); | ||
expect(result.Root.Children).to.have.lengthOf(1); | ||
|
||
expect(result.Root.Children[0].Name).to.equal('Render: index'); | ||
expect(result.Root.Children[0].Children).to.be.empty; | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
var miniprofiler = require('../../../lib/miniprofiler.js'); | ||
var express = require('express'); | ||
|
||
var app = express(); | ||
|
||
app.use(miniprofiler.express()); | ||
app.set('view engine', 'pug'); | ||
app.set('views', './tests/servers/views'); | ||
|
||
app.get('/', (req, res) => { | ||
res.render('index', { title: 'Hey', message: 'Hello there!' }); | ||
}); | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
var miniprofiler = require('../../../lib/miniprofiler.js'); | ||
const Hapi = require('hapi'); | ||
const vision = require('vision'); | ||
|
||
const server = new Hapi.Server(); | ||
server.connection({ port: 8083 }); | ||
|
||
server.register(miniprofiler.hapi(), (err) => { | ||
if (err) throw (err); | ||
}); | ||
|
||
server.register(vision, (err) => { | ||
if (err) throw (err); | ||
|
||
server.views({ | ||
engines: { pug: require('pug') }, | ||
path: './tests/servers/views' | ||
}); | ||
|
||
miniprofiler.hapi().vision(server); | ||
}); | ||
|
||
server.route({ | ||
method: 'GET', | ||
path:'/', | ||
handler: function(request, reply) { | ||
reply.view('index', { title: 'Hey', message: 'Hello there!' }); | ||
} | ||
}); | ||
|
||
module.exports = server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var miniprofiler = require('../../../lib/miniprofiler.js'); | ||
var koa = require('koa'); | ||
var route = require('koa-route'); | ||
var views = require('koa-views'); | ||
var app = koa(); | ||
|
||
app.use(views('./tests/servers/views', { extension: 'pug' })); | ||
|
||
app.use(miniprofiler.koa()); | ||
|
||
app.use(route.get('/', function *(){ | ||
yield this.render('index', { title: 'Hey', message: 'Hello there!' }); | ||
})); | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
html | ||
head | ||
title= title | ||
body | ||
h1= message |