Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pathfinder-ui

Package Overview
Dependencies
Maintainers
5
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathfinder-ui - npm Package Compare versions

Comparing version 0.1.1111 to 0.1.11112

52

lib/pathfinder-ui.js

@@ -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
}
}

4

package.json
{
"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 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc