Skip to content

Instantly share code, notes, and snippets.

@DukeyToo
Created March 16, 2012 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DukeyToo/2051145 to your computer and use it in GitHub Desktop.
Save DukeyToo/2051145 to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
});
app.get('/', function(req, res){
res.send('Hello World\n');
});
app.get('/json', function(req, res){
res.send({ name: 'Tobi', role: 'admin' });
});
function foo(req, res, next) {
next();
}
app.get('/middleware', foo, foo, foo, foo, function(req, res){
res.send('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
});
app.listen(8000);

The perfectapi benchmark used an actual module that uses perfectapi, namely node-sharedmem. This module was chosen because it has no external dependencies, and has very little logic.

var restify = require('restify');
var server = restify.createServer({
name: 'myapp',
});
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.get('/echo/:name', function (req, res, next) {
res.send(req.params);
return next();
});
server.listen(8000, function () {
console.log('%s listening at %s', server.name, server.url);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment