pathfinder-ui
Advanced tools
Comparing version 0.1.1111311 to 0.2.0
@@ -1,5 +0,9 @@ | ||
// app = angular.module([]); | ||
// ^ Once we express.static the entire browser directory | ||
// as well as the angular directory in node_modules, this will | ||
// work. Until then, don't do too much with angular. You won't | ||
// really be able to test it. Maybe. | ||
var app = angular.module('pathfinderApp',['ngMaterial', 'ngMdIcons']) | ||
.config(function($mdThemingProvider){ | ||
$mdThemingProvider.theme('default') | ||
.primaryPalette('pink') | ||
.accentPalette('orange') | ||
.warnPalette('red'); | ||
}) | ||
var example = require('./example'); | ||
var pfroute = require('./pfroute'); | ||
// var Table = require('cli-table'); | ||
// var table = new Table({ head: ["Method", "SubRouter", "Path"] }); | ||
var table = []; | ||
module.exports = startHere; | ||
module.exports = pathfinderUI; | ||
var expressApp = null; | ||
startHere.pfroute = pfroute; | ||
function pathfinderUI (app){ | ||
expressApp = null; | ||
var packageJsonPath = process.cwd() + '/package.json'; | ||
var packageJsonName = require(packageJsonPath).name; | ||
function startHere (app){ | ||
pfroute.request.RESTroutes = generateRouteTree(app); | ||
pfroute.request.RESTroutes = { | ||
routes: generateRouteTree(app), | ||
appId: packageJsonName, | ||
routeTable: table | ||
}; | ||
// pfroute.request.routeTable = table; | ||
function generateRouteTree(app) { | ||
var topLevelRouteStack = app._router.stack; | ||
return retrieveRoutes(topLevelRouteStack); | ||
var routeObj = { | ||
url: packageJsonName, | ||
children: retrieveRoutes(topLevelRouteStack) | ||
}; | ||
return routeObj; | ||
} | ||
function retrieveRoutes (topLevelRouteStack, parentPath) { | ||
// var topLevelRouteStack = app._route.stack; | ||
var allRoutes = []; | ||
var pPath = "" | ||
if(parentPath) pPath = parentPath | ||
var pPath = ""; | ||
if(parentPath) { | ||
if (parentPath === '/'){ | ||
parentPath = ''; | ||
} | ||
pPath = parentPath; | ||
} | ||
@@ -26,47 +52,44 @@ var routesArray = topLevelRouteStack.filter(function(stack){ // filter out middleware | ||
routesArray.forEach(function(e){ | ||
routesArray.map(function(e){ | ||
var parentName; | ||
if (e.route){ // if no subrouter, just direct route | ||
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 | ||
// console.log('something wrong here?',e.regexp.toString().slice(0, -1), e); | ||
var parentName = ''; | ||
if (e.regexp.test('/')){ | ||
parentName = '/'; | ||
if (e.route.path instanceof RegExp) { | ||
e.route.path = "/" + e.route.path.source.match(/\w+/ig).join("/"); | ||
} | ||
else { | ||
parentName = e.regexp.toString().slice(0, -1).match(/\w+/ig).join("/"); | ||
} | ||
//var parentPath = pPath + "/" + e.regexp.toString().slice(0, -1).match(/\w+/ig).join("/"); | ||
var parentPath = pPath + parentName; | ||
//console.log("pName", parentName); | ||
var route = {}; | ||
route[parentName] = []; | ||
var route = { url: pPath + e.route.path, method: e.route.stack[0].method }; | ||
allRoutes.push(route); // add to route tree | ||
route.subRouter = pPath; // add subrouter path | ||
table.push(route); // add to route table | ||
} else if (e.handle.stack) { // if subrouter exists | ||
parentName = '/'; | ||
if (e.regexp.test('/')){ | ||
parentName = '/'; | ||
} | ||
else { | ||
// | ||
parentName = e.regexp.source.match(/\w+/ig).join("/"); | ||
} | ||
// allRoutes.push({path: parentName, method: "router"}) | ||
var subRouterStack = e.handle.stack; // if route is in the handle's stack, retrieve those routes | ||
var parentPath = pPath + "/" +parentName; | ||
if (parentName === '/') parentPath = pPath; | ||
var route = { | ||
url: parentName | ||
}; | ||
route.children = retrieveRoutes(e.handle.stack, parentPath); | ||
allRoutes.push(route); | ||
} else { | ||
//Missed a case | ||
} | ||
route[parentName] = retrieveRoutes(subRouterStack, parentPath); | ||
// console.log("SUBROUTES", subRoutes); | ||
// allRoutes.push(subRoutes) | ||
allRoutes.push(route); | ||
} else { | ||
console.log("missed a case"); | ||
} | ||
}); | ||
return allRoutes; | ||
}); | ||
//console.log(allRoutes); | ||
return allRoutes | ||
} | ||
} | ||
} | ||
} | ||
pathfinderUI.router = pfroute; |
@@ -1,18 +0,36 @@ | ||
/** | ||
* Created by sangmin on 6/29/15. | ||
*/ | ||
// Created By: Sangmin Lee | ||
// Purpose: ???? | ||
// Date: 6/29/15 | ||
var express = require('express'); | ||
var path = require('path'); | ||
var pfrouter = express(); | ||
var fs = require('fs'); | ||
pfrouter.use(express.static(path.join(__dirname, 'browser'))); | ||
pfrouter.use(express.static(path.join(__dirname, '../node_modules/angular'))); | ||
pfrouter.use(express.static(path.join(__dirname, '../node_modules'))); | ||
pfrouter.get('/', function(req, res){ | ||
res.sendFile('./index.html'); | ||
pfrouter.get('/data', function(req, res){ | ||
res.json(req.RESTroutes); | ||
}); | ||
pfrouter.get('/data', function(req, res){ | ||
res.send(req.RESTroutes) | ||
}) | ||
// pfrouter.get('/table', function(req, res) { | ||
// res.json(req.routeTable); | ||
// }) | ||
// pfrouter.get('/history', function(req, res) { | ||
// console.log("dirname", __dirname); | ||
// var pathUrl = path.join(__dirname, '../history/history.json'); | ||
// console.log("pathUrl", pathUrl); | ||
// fs.readFile(pathUrl).then(function(data) { | ||
// console.log(data); | ||
// res.json(data); | ||
// }, function(err) { | ||
// console.log(err); | ||
// }) | ||
// }) | ||
module.exports = pfrouter; |
{ | ||
"name": "pathfinder-ui", | ||
"version": "0.1.1111311", | ||
"version": "0.2.0", | ||
"private": false, | ||
@@ -18,11 +18,12 @@ "preferGlobal": false, | ||
"name": "Ming Lei", | ||
"email": "doop@doop.com" | ||
"email": "mingus718@gmail.com" | ||
}, | ||
{ | ||
"name": "Tyler (Ler) Perwarski", | ||
"email": "loop@loop.com" | ||
"name": "Tyler Pewarski", | ||
"email": "Tjp2122@gmail.com" | ||
} | ||
], | ||
"dependencies": { | ||
"angular": "^1.4.1", | ||
"angular-ui-router": "^0.2.15", | ||
"cli-table": "^0.3.1", | ||
"express": "^4.13.0" | ||
@@ -29,0 +30,0 @@ }, |
@@ -5,27 +5,45 @@ Pathfinder-UI | ||
THIS IS IN ALPHA STAGE. NOT YET FULLY FUNCTIONAL | ||
Pathfinder-UI is a tool that allows you to visualize and test the routes in an express application. | ||
A library that allows developers to visually test their routes. | ||
TEST TEST TEST TEST | ||
## Installation | ||
```bash | ||
npm install pathfinder-ui --save | ||
``` | ||
NPM install the module. | ||
## Usage | ||
Blah blah blah blah ipsum lorsomething dolor darmok and jalad at tanagra | ||
```js | ||
var pathfinderUI = require('pathfinder-ui') | ||
``` | ||
## Tests | ||
Require the module in your app. | ||
Blah blah blah blah ipsum lorsomething dolor darmok and jalad at tanagra | ||
```js | ||
app.use('yourCustomPath', pathfinderUI.router) | ||
app.use('/foo', barmiddleware ) | ||
app.get('/*', foo) | ||
``` | ||
Put the pathfinder-ui routing middleware before your routes. | ||
```js | ||
app.use('/foo', barmiddleware ) | ||
app.get('/*', foo) | ||
pathfinderUI(app); | ||
``` | ||
This function grabs your express routes and passes the data into the module. | ||
Put this line after all of your routes/routers/middlewares. | ||
You access the interface by going to localhost:PORT/yourCustomPath | ||
<!-- ## Tests | ||
## Contributing | ||
Blah blah blah blah ipsum lorsomething dolor darmok and jalad at tanagra. | ||
## Release History | ||
* 0.0.0 some version title stuff | ||
--> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
94896
37
1277
48
3
2
1
+ Addedangular-ui-router@^0.2.15
+ Addedcli-table@^0.3.1
+ Addedangular-ui-router@0.2.18(transitive)
+ Addedcli-table@0.3.11(transitive)
+ Addedcolors@1.0.3(transitive)
- Removedangular@^1.4.1