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

express-ls-routes

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-ls-routes - npm Package Compare versions

Comparing version 0.1.1 to 1.0.2

.idea/jsLibraryMappings.xml

42

lib/middleware.js

@@ -5,15 +5,41 @@ var flatten = require('lodash-node/modern/arrays/flatten')

const isExpress3 = function (app) {
return app._router.map != null
}
const mapExpress3Routes = function (app) {
var routesMap = app._router.map
var methods = Object.keys(routesMap)
return flatten(methods.map(function (method) {
return routesMap[method].map(function (route) {
return format.method(method) + route.path
})
}))
}
const mapExpress4Routes = function (app) {
var ignoredRoutes = ['query', 'expressInit']
return flatten(app._router.stack
.filter(function (entry) {
return ignoredRoutes.indexOf(entry.name) === -1
})
.map(function (entry) {
var route = entry.route
return Object.keys(route.methods)
.filter(function (method) {
return !!route.methods[method]
})
.map(function (method) {
return format.method(method) + route.path
})
})
)
}
module.exports = function (app, options) {
return function (req, res, next) {
var routesMap = app._router.map
var methods = Object.keys(routesMap)
var routes = flatten(methods.map(function (method) {
return routesMap[method].map(function (route) {
return format.method(method) + route.path
})
}))
req.routes = routes
req.routes = isExpress3(app) ? mapExpress3Routes(app) : mapExpress4Routes(app)
next()
}
}
{
"name": "express-ls-routes",
"version": "0.1.1",
"version": "1.0.2",
"description": "Cli and middleware to list routes in your express app",

@@ -22,2 +22,5 @@ "main": "index.js",

"homepage": "https://github.com/jaketrent/express-ls-routes",
"scripts": {
"test": "node_modules/mocha/bin/mocha --harmony \"test/unit/**/*.spec.coffee\""
},
"bin": {

@@ -28,3 +31,9 @@ "routes": "./bin/cli.js"

"lodash-node": "~2.4.1"
},
"devDependencies": {
"coffee-script": "^1.7.1",
"mocha": "^1.20.1",
"rf-release": "^0.1.2",
"should": "^4.0.4"
}
}
}
express-ls-routes
=================
*Updated: supports express3 and express4!*
It's a cli that lets you list the routes in your express app:

@@ -5,0 +7,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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