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

express-list-endpoints

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-list-endpoints - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

6

CHANGELOG.md

@@ -17,2 +17,8 @@ # Changelog

## v4.0.1 - 2019-05-06
### Fixed
- Add logic to avoid duplicate paths #40
## v4.0.0 - 2018-10-14

@@ -19,0 +25,0 @@

6

package.json
{
"name": "express-list-endpoints",
"version": "4.0.0",
"version": "4.0.1",
"description": "A express package to list all registered endoints and its verbs",

@@ -39,8 +39,8 @@ "main": "src/index.js",

"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"express": "^4.16.4",
"mocha": "^5.0.0"
"mocha": "^6.0.0"
}
}

@@ -45,3 +45,8 @@ // var debug = require('debug')('express-list-endpoints')

while (hasParams(parsedRegexp)) {
parsedRegexp = parsedRegexp.toString().replace(/\(\?:\(\[\^\\\/]\+\?\)\)/, ':' + params[paramIdx].name)
var paramId = ':' + params[paramIdx].name
parsedRegexp = parsedRegexp
.toString()
.replace(/\(\?:\(\[\^\\\/]\+\?\)\)/, paramId)
paramIdx++

@@ -67,3 +72,5 @@ }

if (stackItem.route) {
endpoints.push(parseExpressRoute(stackItem.route, basePath))
var endpoint = parseExpressRoute(stackItem.route, basePath)
endpoints = addEndpoint(endpoints, endpoint)
} else if (stackItem.name === 'router' || stackItem.name === 'bound dispatch') {

@@ -84,9 +91,36 @@ if (regexpExpressRegexp.test(stackItem.regexp)) {

/**
* Ensures the path of the new endpoint isn't yet in the array.
* If the path is already in the array merges the endpoint with the existing
* one, if not, it adds it to the array.
*
* @param {Array} endpoints Array of current endpoints
* @param {Object} newEndpoint New endpoint to be added to the array
* @returns {Array} Updated endpoints array
*/
var addEndpoint = function (endpoints, newEndpoint) {
var foundEndpointIdx = endpoints.findIndex(function (item) {
return item.path === newEndpoint.path
})
if (foundEndpointIdx > -1) {
var foundEndpoint = endpoints[foundEndpointIdx]
foundEndpoint.methods = foundEndpoint.methods.concat(newEndpoint.methods)
} else {
endpoints.push(newEndpoint)
}
return endpoints
}
/**
* Returns an array of strings with all the detected endpoints
* @param {Object} app the express/route instance to get the endponts from
* @param {Object} app the express/route instance to get the endpoints from
*/
var getEndpoints = function (app) {
return parseEndpoints(app)
var endpoints = parseEndpoints(app)
return endpoints
}
module.exports = getEndpoints
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