pathfinder-ui
Advanced tools
Comparing version 0.1.1111 to 0.1.11112
@@ -10,4 +10,54 @@ var example = require('./example'); | ||
example(); | ||
function generateRouteTree(app) { | ||
var topLevelRouteStack = app._router.stack; | ||
return retrieveRoutes(topLevelRouteStack); | ||
} | ||
function retrieveRoutes (topLevelRouteStack, parentPath) { | ||
// var topLevelRouteStack = app._route.stack; | ||
var allRoutes = []; | ||
var pPath = "" | ||
if(parentPath) pPath = parentPath | ||
var routesArray = topLevelRouteStack.filter(function(stack){ // filter out middleware | ||
return stack.route || stack.handle.stack; | ||
}); | ||
routesArray.forEach(function(e){ | ||
if (e.route){ // if no subrouter, just direct route | ||
// console.log("ROUTE PATH:", e.route.path, "ROUTE STACK", e.route.stack, "ROUTE STACK[0] METHOD", e.route.stack[0].method); | ||
var route = { path: pPath + e.route.path, method: e.route.stack[0].method }; | ||
allRoutes.push(route); | ||
} else if (e.handle.stack) { // if subrouter exists | ||
//console.log(e.handle.stack); | ||
//{path: grab pathname from the regex exp, method: router} | ||
// test/api | ||
var parentName = e.regexp.toString().slice(0, -1).match(/\w+/ig).join("/"); | ||
var parentPath = pPath + "/" + e.regexp.toString().slice(0, -1).match(/\w+/ig).join("/"); | ||
console.log("pName", parentName); | ||
var route = {}; | ||
route[parentName] = []; | ||
// allRoutes.push({path: parentName, method: "router"}) | ||
var subRouterStack = e.handle.stack; // if route is in the handle's stack, retrieve those routes | ||
route[parentName] = retrieveRoutes(subRouterStack, parentPath); | ||
// console.log("SUBROUTES", subRoutes); | ||
// allRoutes.push(subRoutes) | ||
allRoutes.push(route); | ||
} else { | ||
console.log("missed a case"); | ||
} | ||
}); | ||
return allRoutes | ||
} | ||
} |
{ | ||
"name": "pathfinder-ui", | ||
"version": "0.1.000000001111", | ||
"version": "0.1.11112", | ||
"private": false, | ||
@@ -25,3 +25,3 @@ "preferGlobal": false, | ||
{ | ||
"name": "Tyler Perwarski", | ||
"name": "Tyler (Ler) Perwarski", | ||
"email": "loop@loop.com" | ||
@@ -28,0 +28,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
4190
58
0