Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
new route export parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Oct 29, 2012
1 parent 9df71c1 commit cb021c2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Sérgio Ramos <mail@sergioramos.me>",
"description": "http router",
"main": "src/turnout.js",
"version": "0.0.4",
"version": "0.0.5",
"name": "turnout",
"license": "MIT",
"repository": {
Expand All @@ -25,6 +25,7 @@
"router"
],
"dependencies": {
"match-route": "0.0.x"
"match-route": "0.0.x",
"clone": "0.1.x"
}
}
}
7 changes: 0 additions & 7 deletions src/build.js

This file was deleted.

13 changes: 3 additions & 10 deletions src/parse.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
module.exports.routes = function (routes) {
var returns = new Array()
var obj = new Object()
var returns = Object()

Object.keys(routes).forEach(function (method) {
Object.keys(routes[method]).forEach(function (route) {
if(!obj[route]) obj[route] = [method]
else obj[route].push(method)
if(!returns[route]) returns[route] = [method]
else returns[route].push(method)
})
})

Object.keys(obj).forEach(function (route) {
var topush = {}
topush[route] = obj[route]
returns.push(topush)
})

return returns
}
12 changes: 9 additions & 3 deletions src/turnout.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var mr = require('match-route'),
qs = require('querystring'),
parse = require('./parse'),
build = require('./build'),
clone = require('clone'),
url = require('url')

var defaults = Object()

module.exports = function () {
var routes = build()
var routes = clone(defaults)

var turnout = function (req, res, next) {
mr(req, routes, function (route, params, query) {
Expand Down Expand Up @@ -35,4 +37,8 @@ module.exports = function () {
}

return turnout
}
}

;new Array('get', 'post', 'put', 'delete').forEach(function (method) {
defaults[method] = Object()
})
Empty file removed test/specs/routes.js
Empty file.

0 comments on commit cb021c2

Please sign in to comment.