Skip to content

Commit

Permalink
Query middleware, first test
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed Dec 31, 2012
1 parent 3ff01eb commit 66fde1b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/middleware/query.js
@@ -0,0 +1,12 @@

var url = require('url');

exports = module.exports = createQuery;

function createQuery() {
return function(req, res, next) {
var data = url.parse(req.url, true);
req.query = data.query;
return next();
};
}
4 changes: 4 additions & 0 deletions lib/simpleweb.js
@@ -1,5 +1,7 @@
'use strict';

var query = require('./middleware/query');

exports = module.exports = createApplication;

function createApplication() {
Expand All @@ -24,3 +26,5 @@ function createApplication() {

return app;
};

createApplication.query = query;
5 changes: 5 additions & 0 deletions test/query.js
@@ -0,0 +1,5 @@

var simpleweb = require('..'),
assert = require('assert');
assert.ok(simpleweb.query);assert.equal(typeof simpleweb.query, 'function');var query = simpleweb.query();
assert.ok(query);
Expand Down

0 comments on commit 66fde1b

Please sign in to comment.